diff --git a/CHANGELOG.md b/CHANGELOG.md index 20fa73dc6a7a3d94a00928a647efc68e8e742aa9..b635c23e66a2a36e8716ed47046e42cddda96404 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,23 @@ Recipes must pin the task commit named in the README. Revisions older than v3 let the agent browse the web and routed final answers through Pi; do not use them for new measurements. +## v3.6 (task revision of 2026-11-13) + +This revision replaces the v3.6 task commit of 2026-11-12. Prompts, budgets, time limits, partner +models, grading and scoring are unchanged, and the Gemini results measured on the earlier commit stand. + +- One version for every model. Recipes may use Pi's `openai_responses` and `anthropic_messages` formats + as well as `openai_chat_completions`; `collab-intel-harbor-run` and `-sweep` load recipes with Flock's + loader and launcher and widen only that field. New recipes: Hugging Face router + (`deepseek-hf-full-pi.yaml`), OpenAI Responses (`gpt-full-pi.yaml`) and Anthropic Messages + (`claude-opus-messages-full-pi.yaml`). +- The model gateway forwards an operator-set `X-HF-Bill-To` header (`CI_MODEL_HEADERS`) on the evaluated + model's calls only, and drops any copy a caller sends. +- Clearer module names, no behaviour change: `model_gateway`, `model_gateway_setup`, `flock_results`, + `private_final_answers`, `takeover_grader`, `takeover_verdicts` and `export_evidence` (the verifier + now runs `python -m collab_harbor.export_evidence`). Stored evidence fields keep their names, so saved + runs re-score unchanged. + ## v3.6 - The team service sends the response headers of `team read --wait N` at once and the JSON body when diff --git a/README.md b/README.md index 45e8b87d367511113330e698e3e7b3208a7b7cc0..0b532f0f8e25baabe62b1e6899630dd9d5f1a5e8 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,9 @@ scenarios it solves alone, so compare setups on the scenarios all of them scored ## Results: Gemini 3.8 Flash -Full Pi agent (Pi's own tools and persistent memory), low reasoning effort, this release, three seeds per -scenario; every required run completed. +Full Pi agent (Pi's own tools and persistent memory), low reasoning effort, three seeds per scenario; every +required run completed. Measured on the first v3.6 task commit (2026-11-12). The current revision keeps its +prompts, budgets, time limits and grading, and re-scoring those runs with its code gives the same scores. | Dimension | Test success | Scenarios scored | |---|---|---:| @@ -61,17 +62,17 @@ The run itself reads these variables: | Variable | Used by | |---|---| -| `GEMINI_API_KEY` | the evaluated model and its private final-answer call | +| `GEMINI_API_KEY` (the variable named by the recipe's `inference.api_key_env`) | the evaluated model and its private final-answer call | | `ANTHROPIC_API_KEY`, `OPENAI_API_KEY` | partner models, judges and the Taking-over grader (team container only) | | `HARNESS_VLLM_ENDPOINTS`, `HARNESS_VLLM_API_KEY` | the original Qwen3-14B partner, e.g. `{"Qwen/Qwen3-14B":"https:///v1"}`, reachable from the team container | | `ANTHROPIC_WORKSPACE_ID` | only if your Anthropic key requires a workspace header | **3. Get the tasks and the host tools.** Tag `v3.6` is this README; its tasks are identical to the task -commit `db13809a8fe11ec7e72b7bea2b9b8a1b6928b316`, which the recipes in `examples/` pin. +commit `{{TASK_COMMIT}}`, which the recipes in `examples/` pin. ```sh git lfs install -git clone --branch v3.6 https://huggingface.co/datasets/HuggingFaceSwarms/collaborative-intelligence-harbor ci-harbor +git clone --branch v3.6 https://huggingface.co/datasets/{{REPO}} ci-harbor cd ci-harbor/adapter && uv sync --python 3.13 --locked --extra harbor --extra hub uv pip install --python .venv/bin/python \ 'flock @ git+https://github.com/huggingface/flock.git@f3970bc5e7be2e9d533e33d457e82c41082a7cd3' @@ -92,6 +93,12 @@ collab-intel-harbor-sweep --config examples/gemini-full-pi.yaml --dataset-root . Add `--manifest manifests/taking_over.json` (or `manifest.json` for Sharing) to run one dimension, and use `collab-intel-harbor-run --config examples/gemini-full-pi.yaml` to run only the recipe's single task. +Other models use the same tasks; only the recipe changes. `examples/` also has recipes for a Hugging Face +router model (`deepseek-hf-full-pi.yaml`), OpenAI's Responses API (`gpt-full-pi.yaml`), Anthropic's +Messages API (`claude-opus-messages-full-pi.yaml`) and any OpenAI-compatible endpoint. Set +`CI_MODEL_UPSTREAM` to the provider's base URL when it is not Google's; `adapter/README.md` lists the +formats, the provider routes and how to keep a dataset token and an inference token apart. + **5. Results.** `results/gemini/scores.json` holds Stanford's aggregation per dimension and `progress.json` records every attempt. Each run lives in `results/gemini/cases//flock//trials/*/`: the Pi session under `agent/pi/sessions/`, the team transcript and checker evidence in @@ -116,7 +123,7 @@ the Pi session under `agent/pi/sessions/`, the team transcript and checker evide - `adapter/README.md`: command reference, optional provider recipes, Podman, re-scoring saved runs. - `adapter/RUNTIME.md`: the team service interface and task configuration. - [CHANGELOG.md](CHANGELOG.md): release history. -- The results above were measured on the primary copy, [misc-org/collaborative-intelligence-harbor](https://huggingface.co/datasets/misc-org/collaborative-intelligence-harbor), whose task files are byte-identical to this dataset's. +- {{MIRROR}} ## Licenses and provenance diff --git a/adapter/README.md b/adapter/README.md index 14417e904a48f51ad9c0afcff8a6078b1c7026c8..3046392a741d20a7da67b262e33035e17a936798 100644 --- a/adapter/README.md +++ b/adapter/README.md @@ -40,17 +40,35 @@ collab-intel-harbor-score --manifest $OUT/scoring-manifests/manifests/taking_ove cache. Use the manifests under `$OUT/scoring-manifests/` (`manifest.json` for Sharing), which omit controls that were not run. -## Other models (optional, not benchmarked) - -Only Gemini 3.8 Flash has been evaluated end to end. The other recipes in `examples/` run on the same -pinned Flock with its OpenAI-compatible chat format: - -- `claude-opus-full-pi.yaml`: Claude through Anthropic's OpenAI-compatible endpoint; needs - `ANTHROPIC_API_KEY` (also used by the team) and `ANTHROPIC_WORKSPACE_ID` if your key requires it. -- `endpoint-full-pi.yaml`: any OpenAI-compatible endpoint; set `CI_MODEL_UPSTREAM=https:///v1` - and put the endpoint key in the variable the recipe names (`HF_TOKEN`). - -OpenAI reasoning models need the Responses format, which this Flock version does not support. +## Models and API formats + +The tasks, prompts, budgets and grading are the same for every model. The recipe chooses the model: +`model`, `inference.api_key_env` (the variable holding its key) and `inference.api_format`, the wire format +Pi uses. The task's model gateway serves all three formats and forwards each request to one provider +endpoint, `CI_MODEL_UPSTREAM` (default: Google's OpenAI-compatible endpoint). + +| `api_format` | `inference.base_url` | Use it for | +|---|---|---| +| `openai_chat_completions` | `http://model-compat:8003/v1` | Gemini, Hugging Face router models (e.g. DeepSeek), any OpenAI-compatible endpoint, Claude through Anthropic's OpenAI-compatible endpoint | +| `openai_responses` | `http://model-compat:8003/v1` | OpenAI reasoning models, which reject tools with a reasoning effort on chat completions | +| `anthropic_messages` | `http://model-compat:8003` | Claude through Anthropic's own Messages API | + +`collab-intel-harbor-run` and `-sweep` load recipes with Flock's own loader and launcher; they widen only +`api_format`, which the pinned Flock limits to chat completions, to the three formats Harbor's Pi agent +supports. + +The private final-answer call uses the provider's own client, chosen from the model name: `gemini-*` +Google, `claude-*` Anthropic Messages, `gpt-*` and `o*` OpenAI Responses, any other model an +OpenAI-compatible chat endpoint. Set `CI_MODEL_PROVIDER` (`google`, `anthropic`, `openai`, +`openai-compatible`) to choose it explicitly. + +Recipes in `examples/`: `gemini-full-pi.yaml` (the reference results), `deepseek-hf-full-pi.yaml` +(Hugging Face router), `gpt-full-pi.yaml` (Responses), `claude-opus-messages-full-pi.yaml` (Anthropic Messages), +`claude-opus-full-pi.yaml` (Anthropic's OpenAI-compatible endpoint; set `ANTHROPIC_WORKSPACE_ID` for +either Claude recipe if your key requires it) and +`endpoint-full-pi.yaml` (any OpenAI-compatible endpoint: set `CI_MODEL_UPSTREAM=https:///v1`). +Gemini 3.8 Flash is the evaluated reference; the formats and provider routes of the other recipes are +checked with a scripted fake provider through Pi and Harbor, which shows they run, not how they score. ## Docker and Podman @@ -87,5 +105,18 @@ Keys stay in the launch environment. The evaluated model's key reaches the agent team service (for the private final-answer call); partner, judge and grader keys and the Qwen3-14B endpoint go only to the team service. Submitted code runs in a separate worker without any credentials. +With a Hugging Face model the two Hugging Face roles can need different tokens: one that can read this +private dataset, and one allowed to run inference billed to your organization. Keep them apart: + +```sh +export HF_TOKEN=... # reads the dataset (git, through the askpass helper in the quickstart) +export HF_INFERENCE_TOKEN=... # calls the router; named by the recipe's inference.api_key_env +export CI_MODEL_UPSTREAM=https://router.huggingface.co/v1 +export CI_MODEL_HEADERS='{"X-HF-Bill-To": ""}' # optional: bill the organization +``` + +`CI_MODEL_HEADERS` is sent only on the evaluated model's calls (Pi and its private final answer), never on +partner, judge or grader calls. A single token with both rights can be used for both variables. + See `RUNTIME.md` for the team service interface and task configuration. Retain all upstream licenses, notices and canaries; benchmark material is not training data. diff --git a/adapter/RUNTIME.md b/adapter/RUNTIME.md index f86dcaa63d976c6ff9672ef2cb31f9208e27644f..1a296469aec650488f9735b143d717a0cc22ec94 100644 --- a/adapter/RUNTIME.md +++ b/adapter/RUNTIME.md @@ -39,7 +39,7 @@ seat's private prompt, checker rubric, or answer key is exposed. `POST /reply` accepts `request_id`, `kind`, and `text` for a `message` or `final_answer` request. A `tool` reply accepts `name` and an `arguments` object; -a batch reply can provide a neutral `tool_calls` array with `id`, `name`, and +transport replay can provide a neutral `tool_calls` array with `id`, `name`, and `input` for each call. Tool names must belong to the pending request's tools. One accepted reply returns `{"accepted": true, "request_id": ID}`. An identical retry returns the same acknowledgement; conflicting, stale, and out-of-phase @@ -69,7 +69,7 @@ process group, with bounded escalation from TERM to KILL. The envelope retains the complete upstream transcript after completion and partial observations/actions after interruption. It also records identity, -configuration, lifecycle, and terminal reason. Runtime model +configuration, fixture provenance, lifecycle, and terminal reason. Runtime model configuration is written before the episode starts, so abandonment and completed runs retain the same configuration for aggregation. Per-trial loopback transport ports are normalized in that configuration; the full transcript retains the @@ -81,10 +81,11 @@ With `--taking-over-reader`, generated Taking-over manipulation tasks bake a required `taking_over_reader_gate` policy into both team and verifier metadata. The private worker runs the released Stanford Opus5.5/high/32000 reader and original application rule before publishing a terminal result. A rejected -scripted stop resumes from the original native prefix through `continue_from` and +scripted stop replays the original native prefix through `continue_from` and publishes the next request to the same still-live Pi session. Reader rationale is never inserted into the public observation. Label-changing or unsupported -continuations remain held. +continuations remain held. This is a prospective protocol; it does not recover +lost opaque state from old interrupted sessions. A finished required-reader task cannot fall back to the automatic checker when its reader gate is missing, deferred or malformed. Fresh grading retains the @@ -109,8 +110,12 @@ Required task configuration fields are `scenario_path`, `version`, `seed`, | `initial_request_timeout_sec` | Optional first-request watchdog; disabled by default, or inherits an explicitly supplied request deadline. | | `episode_timeout_sec` | Optional whole-service watchdog; disabled by default. | | `finalize_timeout_sec` | Optional settling watchdog; disabled by default so final teammate/judge requests can finish. | +| `fixture` | Explicit boolean; default false. | | `agent_configuration` | Real evaluated scaffold endpoint/settings metadata. | | `execution_url` | Required isolated pytest worker URL for coding episodes. | +| `execution_tape` | Strict recorded pytest results, permitted only with `fixture: true`. | +| `replay_tape` | Private complete call tape for offline replay. | +| `replay_model` | Native evaluated model name in that tape; default `gemini-3.8-flash`. | `CI_EVALUATED_MODEL` records the actual evaluated model name. `CI_AGENT_CONFIGURATION` can supply the agent metadata as a JSON object. Keep @@ -121,11 +126,33 @@ When `ANTHROPIC_WORKSPACE_ID` is set, live upstream Anthropic clients attach its workspace header without changing model names or judge prompts. The workspace identifier and generated dependency-lock hash are retained in configuration. +Offline replay validates every neutral model-call request against the tape. +Partners and judges receive their recorded results; the evaluated action still +crosses the real loopback SDK bridge and public reply API. Its text and tool +names/arguments must match before the original recorded result metadata is +restored for transcript comparison. A fixture tape always forces the exported +fixture marker, even if configuration incorrectly sets it false. Fixtures must +never enter evaluation scoring. + Coding episodes retain upstream file-tool ownership and history in the episode process. Live pytest execution uses `RemotePytestRunner`; the service requires an -isolated execution URL. Arbitrary submitted code must +isolated execution URL unless running a declared execution-tape fixture. Arbitrary submitted code must never execute in the credential-bearing team service. +For deterministic coding transport replay, a declared fixture can use an +execution tape previously recorded with the isolated worker. Workspace inputs, +pytest settings, and resulting workspace changes must match exactly; all entries +must be consumed. This avoids treating pytest's changing duration text as a +transport mismatch. Independent verifier execution still requires its sandbox. + The service executable supports `--public-host`, `--public-port`, `--internal-port`, and -`--evidence-dir`. The private listener +`--evidence-dir` for isolated local fixture validation. The private listener always binds to loopback. + +Pi 1.5.0 needs the bundled `pi-google.js` extension for Google's compatible +endpoint. It removes Pi's unsupported `store` request field and carries Google's +original opaque thought signatures from raw streamed tool calls into later +assistant history. It neither invents signatures nor changes prompts, tools, +models or reasoning settings. The generated agent image installs the extension +in Pi's extension directory. Six Node checks cover chunked calls, existing +signatures, restart persistence, payload immutability and unrelated models. diff --git a/adapter/VALIDATION.md b/adapter/VALIDATION.md index 5e8071dd2adfae9b901dbf818d59aaa525b9423b..a8220c0751e9172338e033d84878e7d3e8f7924e 100644 --- a/adapter/VALIDATION.md +++ b/adapter/VALIDATION.md @@ -1,5 +1,7 @@ -# Validation +# Release validation -`inventory.json` lists the SHA-256 of every file in this dataset, and `source-lock.json` pins the Stanford source -(`f704b963`). `collab-intel-harbor-sweep --plan-only` checks a recipe against these files without calling a model. -The task files are those the Gemini results in the dataset README were measured on. +The release inventory binds every staged task, source lock and curated adapter file. Only explicitly supplied reports are included under the dataset's reports/ directory. Local synthetic-provider checks establish runtime behavior, not model capability. + +A report validates only its explicitly bound source and runtime. Do not treat a development fixture, this documentation, or a file inventory as proof of model capability or successful execution of a later uploaded revision. Revalidate the actual staged snapshot before publishing. + +Development tests, research controllers and credentials are deliberately excluded; use the development checkout for the full regression suite. diff --git a/adapter/adapter-release.json b/adapter/adapter-release.json index 5fa3a4232d43551c5465ca9f9b52c9a2cbc3bc86..eab6b498a3cae95ecf2c35b229638e89bfbf9bb3 100644 --- a/adapter/adapter-release.json +++ b/adapter/adapter-release.json @@ -2,7 +2,7 @@ "schema_version": 1, "selection": "explicit-wheel-runtime-plus-host-sweep", "files": { - "pyproject.toml": "7c6d4446fa6eb72ff373737383e79bfb3f9cf246196d1724d7831f8f8ad98860", + "pyproject.toml": "6d1081f1b1d5eecded664dd58b7bff90dce1e3c6c4e29829e47b5e324e2ad8e5", "uv.lock": "df9e23033353539e52764c454a95f28b32a7a1a90f1c82facb6ce528f1191911", "src/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "src/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -12,32 +12,33 @@ "src/collab_harbor/command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "src/collab_harbor/compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "src/collab_harbor/continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "src/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "src/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "src/collab_harbor/dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "src/collab_harbor/export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "src/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "src/collab_harbor/generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "src/collab_harbor/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "src/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "src/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "src/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "src/collab_harbor/flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "src/collab_harbor/flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "src/collab_harbor/generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "src/collab_harbor/grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "src/collab_harbor/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "src/collab_harbor/model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "src/collab_harbor/pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "src/collab_harbor/pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "src/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "src/collab_harbor/pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "src/collab_harbor/pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "src/collab_harbor/private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "src/collab_harbor/private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "src/collab_harbor/provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "src/collab_harbor/pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "src/collab_harbor/reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "src/collab_harbor/replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "src/collab_harbor/run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", - "src/collab_harbor/runtime-files.json": "675382b88a6dd8dd23b8825a7017af26d6d0c900c4f6dc6f0ecbd88aea9d0354", + "src/collab_harbor/run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", + "src/collab_harbor/runtime-files.json": "2c91e60ab99be36ae8b28cd1aaa23a2b3b5be4193287f787507f8b3fa7a40726", "src/collab_harbor/runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "src/collab_harbor/scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "src/collab_harbor/sweep.py": "e5c143bd5a2cf75635b49d4bee6c59499637acebb08fbda8a11944419a288028", - "src/collab_harbor/service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "src/collab_harbor/scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "src/collab_harbor/service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "src/collab_harbor/sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "src/collab_harbor/stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "src/collab_harbor/sweep.py": "ad8ecc4681b2f7d9ce810f93137c4918699c6f70299d15050df8ee7d4ad938d2", + "src/collab_harbor/takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "src/collab_harbor/takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "src/collab_harbor/vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "src/collab_harbor/workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, diff --git a/adapter/pyproject.toml b/adapter/pyproject.toml index be0caec4b3c214bf8c43c24cac03ffad7c9cc023..02b84f86a6d032f4bfe2114eaf4ea6f15fae936d 100644 --- a/adapter/pyproject.toml +++ b/adapter/pyproject.toml @@ -41,31 +41,32 @@ only-include = [ "src/collab_harbor/compact_runtime.py", "src/collab_harbor/continuation.py", "src/collab_harbor/dimension_generate.py", - "src/collab_harbor/export.py", + "src/collab_harbor/export_evidence.py", "src/collab_harbor/file_integrity.py", + "src/collab_harbor/flock_config.py", + "src/collab_harbor/flock_results.py", "src/collab_harbor/generate.py", - "src/collab_harbor/google_compat.py", - "src/collab_harbor/google_compat_task.py", "src/collab_harbor/grade.py", - "src/collab_harbor/live_reader_gate.py", + "src/collab_harbor/model_gateway.py", + "src/collab_harbor/model_gateway_setup.py", "src/collab_harbor/pi-bash-timeout.js", "src/collab_harbor/pi-capture.js", "src/collab_harbor/pi-google.js", "src/collab_harbor/pi_bash_timeout.py", "src/collab_harbor/pi_capture.py", - "src/collab_harbor/private_readout.py", + "src/collab_harbor/private_final_answers.py", "src/collab_harbor/provenance.py", "src/collab_harbor/pytest_child.py", - "src/collab_harbor/reader_scoring.py", "src/collab_harbor/replay.py", "src/collab_harbor/run_benchmark.py", "src/collab_harbor/runtime-files.json", "src/collab_harbor/runtime-requirements.lock", "src/collab_harbor/scoring.py", - "src/collab_harbor/sweep.py", "src/collab_harbor/service.py", "src/collab_harbor/sources.py", - "src/collab_harbor/stock_execution.py", + "src/collab_harbor/sweep.py", + "src/collab_harbor/takeover_grader.py", + "src/collab_harbor/takeover_verdicts.py", "src/collab_harbor/vendor.py", "src/collab_harbor/workspace_evidence.py" ] diff --git a/adapter/src/collab_harbor/dimension_generate.py b/adapter/src/collab_harbor/dimension_generate.py index 06e74765cd347206c0324bc5a6a91c3617e120a9..a1bbcdab2742e4bea6996f007abeb32a875cc91d 100644 --- a/adapter/src/collab_harbor/dimension_generate.py +++ b/adapter/src/collab_harbor/dimension_generate.py @@ -90,7 +90,7 @@ def generate_dimension(upstream_dir: Path, output_dir: Path, *, dimension: str, config["grading_protocol"] = "live-full-pi-original-reader-v1" _write(config_path, json.dumps(config, indent=2) + "\n") if taking_over_reader and variant == "manipulation": - from .live_reader_gate import enable_generated_task + from .takeover_grader import enable_generated_task enable_generated_task(staged_task, identity, entry) if target.exists(): shutil.rmtree(target) diff --git a/adapter/src/collab_harbor/export.py b/adapter/src/collab_harbor/export_evidence.py similarity index 100% rename from adapter/src/collab_harbor/export.py rename to adapter/src/collab_harbor/export_evidence.py diff --git a/adapter/src/collab_harbor/flock_config.py b/adapter/src/collab_harbor/flock_config.py new file mode 100644 index 0000000000000000000000000000000000000000..a9e9d4bc6595f214b703af6d000066ae01860a36 --- /dev/null +++ b/adapter/src/collab_harbor/flock_config.py @@ -0,0 +1,25 @@ +"""The experiment config for `collab-intel-harbor-run` and `-sweep`: Flock's own, with all three Pi API formats. + +The pinned Flock accepts only ``inference.api_format: openai_chat_completions``. Harbor's Pi agent, which Flock +launches, also speaks ``openai_responses`` (OpenAI reasoning models) and ``anthropic_messages`` (Claude), and the +task's model gateway serves all three paths. This subclass widens that one field. Every other field, validator, +the YAML loader (``Config.load``) and the launcher (``flock.launch.run_experiment``) are Flock's, unchanged. +""" + +from typing import Literal + +from flock.config import Config as FlockConfig +from flock.config import InferenceSettings +from pydantic import Field + +API_FORMATS = ("openai_chat_completions", "openai_responses", "anthropic_messages") + + +class Inference(InferenceSettings): + api_format: Literal["openai_chat_completions", "openai_responses", "anthropic_messages"] = ( + "openai_chat_completions" + ) + + +class Config(FlockConfig): + inference: Inference = Field(default_factory=Inference) diff --git a/adapter/src/collab_harbor/stock_execution.py b/adapter/src/collab_harbor/flock_results.py similarity index 99% rename from adapter/src/collab_harbor/stock_execution.py rename to adapter/src/collab_harbor/flock_results.py index 18d448fb317c3a35e75b9b35cfbe7054cb47cc49..0e603c96fd6d36265f92cc1009794b13a498f560 100644 --- a/adapter/src/collab_harbor/stock_execution.py +++ b/adapter/src/collab_harbor/flock_results.py @@ -141,7 +141,7 @@ def _completed_before_failure(run, host, trial, evidence): gate = run.get("original_reader_gate") if gate != evidence.get("adapter", {}).get("original_reader_gate"): return None - from .live_reader_gate import apply_final_reader + from .takeover_grader import apply_final_reader checked = apply_final_reader( {"checker": run["checker"], "reward": run["automatic_reward"]}, diff --git a/adapter/src/collab_harbor/generate.py b/adapter/src/collab_harbor/generate.py index 8b431cf783c66f43db3e7a4a80fff8569f87deca..aead83e0497ab9bbc3b2660788e44067dae1bd09 100644 --- a/adapter/src/collab_harbor/generate.py +++ b/adapter/src/collab_harbor/generate.py @@ -406,7 +406,7 @@ timeout_sec = {max(120, 3 * int(episode.get('test_timeout_s', 30)) + 60) if iden [[verifier.collect]] service = "team" -command = "python -m collab_harbor.export" +command = "python -m collab_harbor.export_evidence" timeout_sec = 86400 ''') tests = task / "tests" diff --git a/adapter/src/collab_harbor/grade.py b/adapter/src/collab_harbor/grade.py index 2a9ae0ff701317d8a7767e9d0e81c48b120dc299..f808923125be4e46c0fd1e5db216358f009b18a8 100644 --- a/adapter/src/collab_harbor/grade.py +++ b/adapter/src/collab_harbor/grade.py @@ -192,7 +192,7 @@ def grade_evidence( if (expected["identity"].get("dimension") != "taking_over" or status != "finished" or expected.get("taking_over_reader_gate", {}).get("protocol") != "live-full-pi-original-reader-v1"): raise EvidenceError("Reader gate on an incompatible or incomplete task") - from .live_reader_gate import apply_final_reader + from .takeover_grader import apply_final_reader result = apply_final_reader(result, gate, envelope["transcript"]) return result diff --git a/adapter/src/collab_harbor/google_compat.py b/adapter/src/collab_harbor/model_gateway.py similarity index 93% rename from adapter/src/collab_harbor/google_compat.py rename to adapter/src/collab_harbor/model_gateway.py index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..96dc58b5e6e763197a75c1a95aaec45159dbc864 100644 --- a/adapter/src/collab_harbor/google_compat.py +++ b/adapter/src/collab_harbor/model_gateway.py @@ -22,8 +22,10 @@ unchanged except as noted, to one configured upstream: anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider would fetch them on the agent's behalf. URLs inside plain text are not fetched. * ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). + not send; only ``anthropic-workspace-id``, ``openai-organization``, + ``openai-project`` and ``x-hf-bill-to`` are accepted (an unscoped Anthropic key + needs the first). ``x-hf-bill-to`` (Hugging Face org billing) is operator-only: + a caller's own copy is removed and only the configured value is sent. * A streamed request whose provider is slow (more than 3 s) is answered with a 200 event stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): @@ -32,7 +34,7 @@ unchanged except as noted, to one configured upstream: No credentials are owned or stored (the caller's auth headers pass through), no content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. +ambiguous. """ from __future__ import annotations @@ -56,7 +58,10 @@ ROUTES = { "/v1/responses": "/responses", "/v1/messages": "/messages", } -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} +ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project", "x-hf-bill-to"} +# Set only by the operator (CI_MODEL_HEADERS): a caller's own copy is always removed, so the agent cannot choose +# which organization is billed. +OPERATOR_ONLY_HEADERS = {"x-hf-bill-to"} MAX_BODY = 32 * 1024 * 1024 # Request fields that make the provider fetch or run things server-side. SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} @@ -197,10 +202,15 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N self.wfile.write(b'{"ok":true}') def do_POST(self): - target = ROUTES.get(self.path) + # Route on the path; a query string (the Anthropic SDK's beta client sends /v1/messages?beta=true) + # is forwarded to the provider unchanged. + request_url = urlsplit(self.path) + route = request_url.path + target = ROUTES.get(route) if target is None: self.send_error(404) return + forwarded_path = base_path + target + ("?" + request_url.query if request_url.query else "") try: if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): raise ValueError("A complete JSON Content-Length body is required") @@ -208,7 +218,7 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N if not 0 < length <= MAX_BODY: raise ValueError("Request body size out of bounds") incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) + outgoing = compatible_body(incoming, upstream, path=route, model=model) payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() except (ValueError, TypeError): self.send_error(400, "Unsupported model gateway request") @@ -221,7 +231,8 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N connection = ( http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} + headers = {key: value for key, value in self.headers.items() + if key.lower() not in HOP_BY_HOP and key.lower() not in OPERATOR_ONLY_HEADERS} sent = {key.lower() for key in headers} headers.update({key: value for key, value in extra_headers.items() if key not in sent}) headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", @@ -245,7 +256,7 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N provider_sock["sock"] = connection.sock if provider_sock.get("aborted"): raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) + connection.request("POST", forwarded_path, payload, headers) result["response"] = connection.getresponse() except (OSError, http.client.HTTPException) as error: result["error"] = error @@ -324,7 +335,7 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N if response is not None and response.status == 200 and encoding != "identity": # Our headers are already sent without Content-Encoding: never relay bytes the caller # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " + self.wfile.write(stream_error(route, f"Upstream sent Content-Encoding {encoding!r} " "despite Accept-Encoding: identity", 502)) self.wfile.flush() self.close_connection = True @@ -334,7 +345,7 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" message = (f"Upstream HTTP {status}: {detail}" if response is not None else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) + self.wfile.write(stream_error(route, message, status)) self.wfile.flush() self.close_connection = True return diff --git a/adapter/src/collab_harbor/google_compat_task.py b/adapter/src/collab_harbor/model_gateway_setup.py similarity index 94% rename from adapter/src/collab_harbor/google_compat_task.py rename to adapter/src/collab_harbor/model_gateway_setup.py index bee92ce6fe5c3fcbafd9fa41992ad376bc91e610..7386ace2e5b3a84cd4b62787a75a6372a19f55c7 100644 --- a/adapter/src/collab_harbor/google_compat_task.py +++ b/adapter/src/collab_harbor/model_gateway_setup.py @@ -33,15 +33,15 @@ def install(task): raise ValueError("Task must preserve public install and restricted agent network phases") owned = task / "environment/model-compat" owned.mkdir(exist_ok=False) - source = Path(__file__).with_name("google_compat.py") - shutil.copyfile(source, owned / "google_compat.py") + source = Path(__file__).with_name("model_gateway.py") + shutil.copyfile(source, owned / "model_gateway.py") ( owned / "Dockerfile" ).write_text("""FROM python:3.13-slim-bookworm@sha256:281d39ff02e3b389401586134ff9e6572954687822a58055ec07a60ded4e0b7f -COPY google_compat.py /app/google_compat.py -RUN chmod 644 /app/google_compat.py +COPY model_gateway.py /app/model_gateway.py +RUN chmod 644 /app/model_gateway.py USER 65534:65534 -ENTRYPOINT ["python", "-B", "/app/google_compat.py"] +ENTRYPOINT ["python", "-B", "/app/model_gateway.py"] """) compose["services"]["model-compat"] = { "build": {"context": "./model-compat"}, @@ -122,7 +122,6 @@ def main(): { "tasks": len(selected), "optional_model_compat": True, - "model": "gemini-3.8-flash", } ) ) diff --git a/adapter/src/collab_harbor/private_readout.py b/adapter/src/collab_harbor/private_final_answers.py similarity index 100% rename from adapter/src/collab_harbor/private_readout.py rename to adapter/src/collab_harbor/private_final_answers.py diff --git a/adapter/src/collab_harbor/run_benchmark.py b/adapter/src/collab_harbor/run_benchmark.py index 8cef531aed98eaaecdec51ac8eca4aaa229f7958..8117356635c4db810e2abb9df0d3a031105a1b89 100644 --- a/adapter/src/collab_harbor/run_benchmark.py +++ b/adapter/src/collab_harbor/run_benchmark.py @@ -125,7 +125,6 @@ PROVIDERS = { "anthropic": ("https://api.anthropic.com/v1", "anthropic-messages"), "openai-compatible": (None, "openai-compat-chat"), } -API_FORMATS = {"openai_chat_completions", "openai_responses", "anthropic_messages"} def provider_for(evaluated, environ): @@ -145,7 +144,7 @@ def provider_for(evaluated, environ): def model_route(config, evaluated, environ): """The gateway upstream and private-readout settings for this recipe; no network.""" - from collab_harbor.google_compat import validate_upstream + from collab_harbor.model_gateway import validate_upstream provider = provider_for(evaluated, environ) default, readout_api = PROVIDERS[provider] @@ -167,6 +166,8 @@ def model_route(config, evaluated, environ): def validate_recipe(config, evaluated, version): """The fixed Full Pi protocol; the model and provider are free.""" + from collab_harbor.flock_config import API_FORMATS + expected_base = GATEWAY if config.inference.api_format == "anthropic_messages" else GATEWAY + "/v1" if ( version != "1.5.0" @@ -183,10 +184,27 @@ def validate_recipe(config, evaluated, version): ) +def gateway_routing_headers(route, environ): + """Non-secret routing headers for the task's model gateway (CI_MODEL_HEADERS). + + The operator's own CI_MODEL_HEADERS are validated and kept exactly (e.g. Hugging Face org billing, + {"X-HF-Bill-To": ""}); for Anthropic models the workspace header is added when not already set. Only the + model-compat service reads them, so they apply to the evaluated model's calls (Pi and the private final + answer) and never to the team's partner, judge or grader routes.""" + from collab_harbor.model_gateway import routing_headers + + headers = routing_headers(environ.get("CI_MODEL_HEADERS")) + workspace = environ.get("ANTHROPIC_WORKSPACE_ID") + if route["provider"] == "anthropic" and workspace: + headers.setdefault("anthropic-workspace-id", workspace) + return headers + + def main(): - from flock.config import Config from flock.launch import run_experiment + from collab_harbor.flock_config import Config + parser = argparse.ArgumentParser(description=__doc__) parser.add_argument("--config", type=Path, required=True) args = parser.parse_args() @@ -195,7 +213,9 @@ def main(): validate_recipe(config, evaluated, configuration["version"]) configuration["original_roles"] = original_role_configuration(os.environ) route = model_route(config, evaluated, os.environ) + gateway_headers = gateway_routing_headers(route, os.environ) configuration["model_gateway"] = { + "routing_headers": gateway_headers, "provider": route["provider"], "upstream": route["upstream"], "private_readout_api": route["readout_api"], @@ -203,7 +223,7 @@ def main(): configuration["task_local_model_compatibility"] = { "mode": "provider-neutral gateway; removes top-level store for Google only", "source_sha256": hashlib.sha256( - Path(__file__).with_name("google_compat.py").read_bytes() + Path(__file__).with_name("model_gateway.py").read_bytes() ).hexdigest(), "covers_internal_pi_compaction": True, } @@ -211,9 +231,7 @@ def main(): os.environ["CI_AGENT_CONFIGURATION"] = json.dumps(configuration, allow_nan=False) # Read by docker compose interpolation for model-compat (upstream) and team (readout). os.environ["CI_MODEL_UPSTREAM"] = route["upstream"] - workspace = os.environ.get("ANTHROPIC_WORKSPACE_ID") - os.environ["CI_MODEL_HEADERS"] = json.dumps( - {"anthropic-workspace-id": workspace} if route["provider"] == "anthropic" and workspace else {}) + os.environ["CI_MODEL_HEADERS"] = json.dumps(gateway_headers) os.environ["CI_PRIVATE_READOUT_API"] = route["readout_api"] os.environ["CI_PRIVATE_READOUT_BASE_URL"] = GATEWAY + "/v1" os.environ["CI_PRIVATE_READOUT_EFFORT"] = route["effort"] diff --git a/adapter/src/collab_harbor/runtime-files.json b/adapter/src/collab_harbor/runtime-files.json index ac48c39a1fab06ef89e865ea69b318774a56ee09..7280a2c0f5cf1e5303a1304838e7e61a8215eedc 100644 --- a/adapter/src/collab_harbor/runtime-files.json +++ b/adapter/src/collab_harbor/runtime-files.json @@ -10,22 +10,22 @@ "compact_runtime.py", "continuation.py", "dimension_generate.py", - "export.py", + "export_evidence.py", "file_integrity.py", + "flock_config.py", + "flock_results.py", "generate.py", - "google_compat.py", - "google_compat_task.py", "grade.py", - "live_reader_gate.py", + "model_gateway.py", + "model_gateway_setup.py", "pi-bash-timeout.js", "pi-capture.js", "pi-google.js", "pi_bash_timeout.py", "pi_capture.py", - "private_readout.py", + "private_final_answers.py", "provenance.py", "pytest_child.py", - "reader_scoring.py", "replay.py", "run_benchmark.py", "runtime-files.json", @@ -33,7 +33,8 @@ "scoring.py", "service.py", "sources.py", - "stock_execution.py", + "takeover_grader.py", + "takeover_verdicts.py", "vendor.py", "workspace_evidence.py" ] diff --git a/adapter/src/collab_harbor/scoring.py b/adapter/src/collab_harbor/scoring.py index d799671d3156d3a4b1a223a26799d85973ac651a..0bb5d2438dae386edc6af5f5d7cb1161ef544aea 100644 --- a/adapter/src/collab_harbor/scoring.py +++ b/adapter/src/collab_harbor/scoring.py @@ -248,7 +248,7 @@ def score_runs( key = _key(run["identity"]) if key in indexed or key in unavailable: raise ValueError(f"Duplicate run in one configuration: {key}") - from .stock_execution import unavailable_reason + from .flock_results import unavailable_reason host_unavailable = unavailable_reason(run) if host_unavailable: unavailable[key] = host_unavailable @@ -273,7 +273,7 @@ def score_runs( raise ValueError(f"Transcript version/seed does not match its envelope: {key}") if type((transcript.get("score") or {}).get("pass")) is not bool and not transcript.get("judge_failed"): raise ValueError(f"Completed transcript lacks a boolean checker verdict: {key}") - from .reader_scoring import effective_record + from .takeover_verdicts import effective_record indexed[key] = effective_record(run, manifest) scenarios = list(dict.fromkeys(key[0] for key in expected)) @@ -379,7 +379,7 @@ def main(argv: list[str] | None = None) -> int: upstream = ensure_upstream(upstream) sys.path.insert(0, str(upstream / "src")) try: - from .stock_execution import load_runs + from .flock_results import load_runs report = score_runs( load_runs(args.runs, args.flock_run), json.loads(args.manifest.read_text()), diff --git a/adapter/src/collab_harbor/service.py b/adapter/src/collab_harbor/service.py index 354c84b3f35fa3fc84c47610a00e03ba08f9b147..88969311bbb4d6c1cc46fc01da942874f220c942 100644 --- a/adapter/src/collab_harbor/service.py +++ b/adapter/src/collab_harbor/service.py @@ -234,7 +234,7 @@ class EpisodeService: if config.get("grading_protocol"): self.configuration["grading_protocol"] = config["grading_protocol"] if config.get("private_final_readout") is not None: - from .private_readout import PROTOCOL + from .private_final_answers import PROTOCOL if config["private_final_readout"] != {"protocol": PROTOCOL}: raise ValueError("Unknown private final readout protocol") self.configuration["final_readout_protocol"] = PROTOCOL @@ -761,7 +761,7 @@ def episode_worker(config: dict) -> None: original = llm.call_model dispatch = original if config.get("private_final_readout"): - from .private_readout import PrivateFinalReadout + from .private_final_answers import PrivateFinalReadout readout = PrivateFinalReadout(llm, original, config) resources.callback(readout.close) @@ -788,7 +788,7 @@ def episode_worker(config: dict) -> None: workspace_context = nullcontext(None) with context, execution_context, integrity_context, workspace_context as workspace_capture: if config.get("taking_over_reader_gate"): - from .live_reader_gate import run_live_gate + from .takeover_grader import run_live_gate transcript, reader_workspace, reader_gate_result = run_live_gate(episode, llm, source, config) elif config.get("stop_continuation"): from .continuation import run_original @@ -816,7 +816,7 @@ def episode_worker(config: dict) -> None: except BaseException as error: # Provider exception strings can contain request bodies. Keep the public # reason categorical; the private worker log retains the traceback. - from .live_reader_gate import recovery_evidence + from .takeover_grader import recovery_evidence recovery = getattr(error, "reader_deferred", None) or recovery_evidence(result_path.parent) atomic_json(result_path, {"status": "infrastructure_error", "reason": type(error).__name__, diff --git a/adapter/src/collab_harbor/sweep.py b/adapter/src/collab_harbor/sweep.py index 8cad7f5ecef50e7b51dea91fe5a90a93b8329757..5768db15fb3144bc05cd4388d4b8b21e88625673 100644 --- a/adapter/src/collab_harbor/sweep.py +++ b/adapter/src/collab_harbor/sweep.py @@ -232,8 +232,8 @@ class Sweep: return "waiting_for_gate" def collect(self, case): - from collab_harbor.reader_scoring import effective_record - from collab_harbor.stock_execution import load_runs, unavailable_reason + from collab_harbor.flock_results import load_runs, unavailable_reason + from collab_harbor.takeover_verdicts import effective_record directory = self.output / "cases" / case hosts = list((directory / "flock").glob("*/run.json")) @@ -291,7 +291,7 @@ class Sweep: } async def execute(self, case): - from flock.config import Config + from collab_harbor.flock_config import Config directory = self.output / "cases" / case directory.mkdir(parents=True, exist_ok=True) @@ -448,8 +448,8 @@ class Sweep: ) def scores(self): + from collab_harbor.flock_results import load_runs from collab_harbor.scoring import score_runs - from collab_harbor.stock_execution import load_runs reports = {} for group, manifest in self.groups.items(): @@ -471,8 +471,7 @@ class Sweep: def main(): - from flock.config import Config - + from collab_harbor.flock_config import Config from collab_harbor.run_benchmark import ( metadata, original_role_configuration, @@ -551,7 +550,7 @@ def main(): ) # Validate original panel config before any paid case. for case, row in sweep.cases.items(): task = args.dataset_root / checked_relative(row["path"]) - if not (task / "environment/model-compat/google_compat.py").is_file(): + if not (task / "environment/model-compat/model_gateway.py").is_file(): raise ValueError( "Rebuilt task-local model-compat sidecar required; old published revision is incompatible" ) diff --git a/adapter/src/collab_harbor/live_reader_gate.py b/adapter/src/collab_harbor/takeover_grader.py similarity index 100% rename from adapter/src/collab_harbor/live_reader_gate.py rename to adapter/src/collab_harbor/takeover_grader.py diff --git a/adapter/src/collab_harbor/reader_scoring.py b/adapter/src/collab_harbor/takeover_verdicts.py similarity index 98% rename from adapter/src/collab_harbor/reader_scoring.py rename to adapter/src/collab_harbor/takeover_verdicts.py index 659efcdec14bc2a079afab0d6bbf28fa864fd3a0..d655ae069ec09345245964329b3e7512ea813a3e 100644 --- a/adapter/src/collab_harbor/reader_scoring.py +++ b/adapter/src/collab_harbor/takeover_verdicts.py @@ -35,7 +35,7 @@ def effective_record(run, manifest): raise ValueError( "Finished TakingOver test lacks its required applied original reading" ) - from collab_harbor.live_reader_gate import apply_final_reader + from collab_harbor.takeover_grader import apply_final_reader automatic = run.get("automatic_reward") checker = run.get("checker") diff --git a/examples/claude-opus-full-pi.yaml b/examples/claude-opus-full-pi.yaml index f7e128b654d95de999749c71d01c980d38675010..a0530f95197826c7dcabaf5b86ea9b73eff63f9d 100644 --- a/examples/claude-opus-full-pi.yaml +++ b/examples/claude-opus-full-pi.yaml @@ -10,8 +10,8 @@ inference: api_format: openai_chat_completions reasoning_effort: low task: - repo: https://huggingface.co/datasets/HuggingFaceSwarms/collaborative-intelligence-harbor - revision: db13809a8fe11ec7e72b7bea2b9b8a1b6928b316 + repo: https://huggingface.co/datasets/{{REPO}} + revision: {{TASK_COMMIT}} selector: ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0 agents: count: 1 diff --git a/examples/claude-opus-messages-full-pi.yaml b/examples/claude-opus-messages-full-pi.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8e0850db51e0065a8ed787c0ee7b2a534335d921 --- /dev/null +++ b/examples/claude-opus-messages-full-pi.yaml @@ -0,0 +1,24 @@ +# Claude through Anthropic's own Messages API. Needs ANTHROPIC_API_KEY (also used by the team) and +# ANTHROPIC_WORKSPACE_ID if your key requires it. Note the base URL has no /v1: Pi adds /v1/messages. +# collab-intel-harbor-run --config examples/claude-opus-messages-full-pi.yaml +name: ci-fullpi-claude-messages +harness: pi +model: anthropic/claude-opus-5-5 +inference: + base_url: http://model-compat:8003 + api_key_env: ANTHROPIC_API_KEY + api_format: anthropic_messages + reasoning_effort: low +task: + repo: https://huggingface.co/datasets/{{REPO}} + revision: {{TASK_COMMIT}} + selector: ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0 +agents: + count: 1 +environment: + backend: docker +limits: + run_timeout_seconds: 3600 + agent_max_turns: 256 + agent_timeout_seconds: null +output_dir: results diff --git a/examples/deepseek-hf-full-pi.yaml b/examples/deepseek-hf-full-pi.yaml new file mode 100644 index 0000000000000000000000000000000000000000..7947c46be43f4cace0ed74fcdad4af54eee58e21 --- /dev/null +++ b/examples/deepseek-hf-full-pi.yaml @@ -0,0 +1,24 @@ +# DeepSeek-V4.1-Flash through the Hugging Face router (OpenAI-compatible chat). +# Needs: CI_MODEL_UPSTREAM=https://router.huggingface.co/v1, the inference token in HF_INFERENCE_TOKEN, +# HF_TOKEN for reading the dataset, and optionally CI_MODEL_HEADERS='{"X-HF-Bill-To": ""}'. +# collab-intel-harbor-run --config examples/deepseek-hf-full-pi.yaml +name: ci-fullpi-deepseek-hf +harness: pi +model: openai/deepseek-ai/DeepSeek-V4.1-Flash +inference: + base_url: http://model-compat:8003/v1 + api_key_env: HF_INFERENCE_TOKEN + api_format: openai_chat_completions +task: + repo: https://huggingface.co/datasets/{{REPO}} + revision: {{TASK_COMMIT}} + selector: ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0 +agents: + count: 1 +environment: + backend: docker +limits: + run_timeout_seconds: 3600 + agent_max_turns: 256 + agent_timeout_seconds: null +output_dir: results diff --git a/examples/endpoint-full-pi.yaml b/examples/endpoint-full-pi.yaml index b05d66983e97d12425fefc197421d887892642ea..51d83092723f941b89b3b4ae557ffd51f3e1de30 100644 --- a/examples/endpoint-full-pi.yaml +++ b/examples/endpoint-full-pi.yaml @@ -9,8 +9,8 @@ inference: api_key_env: HF_TOKEN api_format: openai_chat_completions task: - repo: https://huggingface.co/datasets/HuggingFaceSwarms/collaborative-intelligence-harbor - revision: db13809a8fe11ec7e72b7bea2b9b8a1b6928b316 + repo: https://huggingface.co/datasets/{{REPO}} + revision: {{TASK_COMMIT}} selector: ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0 agents: count: 1 diff --git a/examples/gemini-full-pi.yaml b/examples/gemini-full-pi.yaml index 29b344a83102b9b9b0588ee3086154cfad68c95d..fd8ec0c66ff2a9e6f0f841b5bc62931be06f2e8e 100644 --- a/examples/gemini-full-pi.yaml +++ b/examples/gemini-full-pi.yaml @@ -10,8 +10,8 @@ inference: api_format: openai_chat_completions reasoning_effort: low task: - repo: https://huggingface.co/datasets/HuggingFaceSwarms/collaborative-intelligence-harbor - revision: db13809a8fe11ec7e72b7bea2b9b8a1b6928b316 + repo: https://huggingface.co/datasets/{{REPO}} + revision: {{TASK_COMMIT}} selector: ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0 agents: count: 1 diff --git a/examples/gpt-full-pi.yaml b/examples/gpt-full-pi.yaml new file mode 100644 index 0000000000000000000000000000000000000000..67285ef066f2de5b4b1803fbc1af90b0f79752c0 --- /dev/null +++ b/examples/gpt-full-pi.yaml @@ -0,0 +1,23 @@ +# OpenAI reasoning models through OpenAI's Responses API. Needs OPENAI_API_KEY (also used by the team). +# collab-intel-harbor-run --config examples/gpt-full-pi.yaml +name: ci-fullpi-gpt +harness: pi +model: openai/gpt-6.1-sol +inference: + base_url: http://model-compat:8003/v1 + api_key_env: OPENAI_API_KEY + api_format: openai_responses + reasoning_effort: low +task: + repo: https://huggingface.co/datasets/{{REPO}} + revision: {{TASK_COMMIT}} + selector: ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0 +agents: + count: 1 +environment: + backend: docker +limits: + run_timeout_seconds: 3600 + agent_max_turns: 256 + agent_timeout_seconds: null +output_dir: results diff --git a/inventory.json b/inventory.json index 759f4726b56cadd08020da44bd4588ee0631f370..fafcafa0258cf2583e7a62ce8cc17656d3742557 100644 --- a/inventory.json +++ b/inventory.json @@ -1,18 +1,18 @@ { "schema_version": 1, "files": { - "CHANGELOG.md": "48a3fe11dec2e383bca84fede05acac4de72ba0c253a8c7a716d6559d6f70fa0", + "CHANGELOG.md": "f1d22534fd9479d6ec1e8f14e910d400fb2e0ce91eea389b9c2b5a627aa320f9", "LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", "LICENSE-DATA": "5e7a6e49010ac248c5467d12cfc064201a2d2d78e02004bc6e72a36f6636a5b3", "LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", - "README.md": "a4159537dbe1644c7386101eed623747b36f8cd37f0f4223a219ba259fada503", + "README.md": "62969318c991e09ddb0f01d218ef5b096a393485bab05814db0bb3502548226e", "THIRD_PARTY_NOTICES.md": "30b361cb67a2142b25db00158144c4ddd5ad5c248e2c75bd9b48e2e0fab8fa33", "adapter/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", - "adapter/README.md": "05bb068a33aa2921607e51f579af32c5e54882370776a93d59f799bce5d914d0", - "adapter/RUNTIME.md": "2b08f60f9abf3d3212f0fbe50133711e7419caef472c7eb6051c9e32f3e5a87d", - "adapter/VALIDATION.md": "1d4348c11a1dc71f206eec0665e3ef98ed34c036799a909439abdd034ec213e3", - "adapter/adapter-release.json": "8da64fec5cf746301808cac500239f8915ccfd6f376ad0bd2218e67e7ad4fd5c", - "adapter/pyproject.toml": "7c6d4446fa6eb72ff373737383e79bfb3f9cf246196d1724d7831f8f8ad98860", + "adapter/README.md": "55e2d79097a8322c25b5ddb02d79b55771d21f1e366518183227194c00631042", + "adapter/RUNTIME.md": "6922f05963d09e9c606237eb8851d8781b5ec316de84316d31fc0b55eff3b060", + "adapter/VALIDATION.md": "f46858c206a28c8d540773c52af2b8176cf2abf4e1be6fe8a83486500da508c5", + "adapter/adapter-release.json": "59e86d8c182dadca6ff75e41c58f74e1a1154b4933a358ad1865e02d58f6c385", + "adapter/pyproject.toml": "6d1081f1b1d5eecded664dd58b7bff90dce1e3c6c4e29829e47b5e324e2ad8e5", "adapter/src/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/src/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", "adapter/src/collab_harbor/checker_execution.py": "1a3134c7835bd931bfd003944c316f73763ae2f6e029159b209bd5dd2d88942d", @@ -21,39 +21,43 @@ "adapter/src/collab_harbor/command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "adapter/src/collab_harbor/compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "adapter/src/collab_harbor/continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "adapter/src/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "adapter/src/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "adapter/src/collab_harbor/dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "adapter/src/collab_harbor/export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/src/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/src/collab_harbor/generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "adapter/src/collab_harbor/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "adapter/src/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "adapter/src/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "adapter/src/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/src/collab_harbor/flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "adapter/src/collab_harbor/flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "adapter/src/collab_harbor/generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "adapter/src/collab_harbor/grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "adapter/src/collab_harbor/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "adapter/src/collab_harbor/model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "adapter/src/collab_harbor/pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "adapter/src/collab_harbor/pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "adapter/src/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "adapter/src/collab_harbor/pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "adapter/src/collab_harbor/pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "adapter/src/collab_harbor/private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "adapter/src/collab_harbor/private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "adapter/src/collab_harbor/provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "adapter/src/collab_harbor/pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "adapter/src/collab_harbor/reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "adapter/src/collab_harbor/replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "adapter/src/collab_harbor/run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", - "adapter/src/collab_harbor/runtime-files.json": "675382b88a6dd8dd23b8825a7017af26d6d0c900c4f6dc6f0ecbd88aea9d0354", + "adapter/src/collab_harbor/run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", + "adapter/src/collab_harbor/runtime-files.json": "2c91e60ab99be36ae8b28cd1aaa23a2b3b5be4193287f787507f8b3fa7a40726", "adapter/src/collab_harbor/runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "adapter/src/collab_harbor/scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "adapter/src/collab_harbor/service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "adapter/src/collab_harbor/scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "adapter/src/collab_harbor/service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "adapter/src/collab_harbor/sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "adapter/src/collab_harbor/stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", - "adapter/src/collab_harbor/sweep.py": "e5c143bd5a2cf75635b49d4bee6c59499637acebb08fbda8a11944419a288028", + "adapter/src/collab_harbor/sweep.py": "ad8ecc4681b2f7d9ce810f93137c4918699c6f70299d15050df8ee7d4ad938d2", + "adapter/src/collab_harbor/takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/src/collab_harbor/takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "adapter/src/collab_harbor/vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "adapter/src/collab_harbor/workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8", "adapter/uv.lock": "df9e23033353539e52764c454a95f28b32a7a1a90f1c82facb6ce528f1191911", "catalog.json": "3056cc803e2e07da5854f80af3dc0886930c87f003eeae27b07247b8dc81e477", - "examples/claude-opus-full-pi.yaml": "f7bc2ec9edebeac727c67a6661a8f0b810892aeb50798fccae3558673f336c5d", - "examples/endpoint-full-pi.yaml": "a9866c69052da88355a5c01d6e4ca1dcc3dd4c3022b30cde3ca266320a267e43", - "examples/gemini-full-pi.yaml": "c3c41e677ede5e6e9f19db2c01eb55686707c2e9c9ef9a9186db4ce43f7d2e4f", + "examples/claude-opus-full-pi.yaml": "6950c70d8db43d34a47e22c60aa8ee1ff57fe05a21615c49f9bcdfde4dbe4762", + "examples/claude-opus-messages-full-pi.yaml": "a9ea74ac20278f70620e0f4b1c1af6fdc4f533a640a0f7285ac9984cc5e46d58", + "examples/deepseek-hf-full-pi.yaml": "5dac3f4d2e207e77d0768a50a2a6f56316bcdb0778b46e2fe4566251218be5b1", + "examples/endpoint-full-pi.yaml": "4c911454874543d2db375401026c85bc3efa2e5938175c19b5058479ee79fd3e", + "examples/gemini-full-pi.yaml": "ea9a40caa19acd5fe9368ae403c064841e2423717f08a2135f3100764ae61289", + "examples/gpt-full-pi.yaml": "fb3f92983c9b1f09409e4825ddefc41e4103e507397e1276b14a0af0d165b25d", "manifest.json": "836fd5cdf6df5a3acef54b699cdf4b9f7f831de6858f8e8d8d3202a67470bec5", "manifests/keeping_the_team_on_track.json": "39ba992343ec338cfd563d8c5428bef3534fb19f0f44d4080b24928c2fb06ab2", "manifests/taking_initiative.json": "c4fbb6335103cd505c5a723452a4b2eccd0bd626b3a209bc3d2b58d089bde529", @@ -72,30 +76,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/docker-compose.yaml": "cbf76a24f69fb8d2eb7cc08cbce3500a44f46ee1a4492ca434c1aa4a488d16d3", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/scenario/episode.yaml": "d2b3df2e1a86f26df105d3ee6c79b131ab3e525eb0bb1fb2cd7ecb758de04370", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/scenario/notes.md": "0d48feab03cdd1f71ae276a59da9d93ac9347bffb1620cda1984b587d5c0cb98", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/scenario/record.json": "39e3858efa58028493ce5bd6ec7f4e66215eda34668304fee98934b2d7acdaf7", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/scenario/source.md": "f4dd9f2c103d01f810bf274e9eac3a78058a68ba14308909b10fa5530a9a03bc", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/task.json": "bb61bb04d7e9cebb90bdad080ae1a36f5574741b4e225bb0a97bfd488ea003bc", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/task.json": "deaef6e885db38bb1a0b81fe865ba8a1272e9ebff4282d51aa1f024bcad387a8", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/task.toml": "309002a9ad423e8e050632ef03a192bf48410ab567a260c8b1ca8a83ab9ccfd3", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/task.toml": "f16c4aa50edc51692d785636a69f23f8114a97c726538492dfc771e269020418", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/expected.json": "a98451669797660c4f13f50e70e0e66b9760744ad407cb952f30f360ea932210", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/scenario/episode.yaml": "d2b3df2e1a86f26df105d3ee6c79b131ab3e525eb0bb1fb2cd7ecb758de04370", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/scenario/notes.md": "0d48feab03cdd1f71ae276a59da9d93ac9347bffb1620cda1984b587d5c0cb98", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/scenario/record.json": "39e3858efa58028493ce5bd6ec7f4e66215eda34668304fee98934b2d7acdaf7", @@ -114,30 +118,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/docker-compose.yaml": "861cd2651ef913b7d04e414314a8e344ce6614976e0aa92b4619987b5830832d", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/scenario/episode.yaml": "d2b3df2e1a86f26df105d3ee6c79b131ab3e525eb0bb1fb2cd7ecb758de04370", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/scenario/notes.md": "0d48feab03cdd1f71ae276a59da9d93ac9347bffb1620cda1984b587d5c0cb98", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/scenario/record.json": "39e3858efa58028493ce5bd6ec7f4e66215eda34668304fee98934b2d7acdaf7", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/scenario/source.md": "f4dd9f2c103d01f810bf274e9eac3a78058a68ba14308909b10fa5530a9a03bc", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/task.json": "2e201a1d0d2aa003578023f338e60c1a1528d79934b1034dfb3630acc41bfa37", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/task.json": "e57545375c8a3503e165e8d76073f89c580ae9df5573797e42622224965e88eb", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/task.toml": "606a0b37b99f060e2b854e7fd00f826350aa7c5ee3d52b6a6cbb926ecbcaabf0", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/task.toml": "9be23775c2b11ed61986254654377f49984dea7b97f7d1166fdbb4cfedbf4821", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/expected.json": "7be5ee3b28e158ee63387738a43f6b60f293fcc6e67042b752bf677a88410f08", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/scenario/episode.yaml": "d2b3df2e1a86f26df105d3ee6c79b131ab3e525eb0bb1fb2cd7ecb758de04370", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/scenario/notes.md": "0d48feab03cdd1f71ae276a59da9d93ac9347bffb1620cda1984b587d5c0cb98", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/scenario/record.json": "39e3858efa58028493ce5bd6ec7f4e66215eda34668304fee98934b2d7acdaf7", @@ -156,30 +160,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/docker-compose.yaml": "b648b0a9f011df1fa60644146bb82ead3e163c88f98cd59680840842bd3d75d2", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/scenario/episode.yaml": "d2b3df2e1a86f26df105d3ee6c79b131ab3e525eb0bb1fb2cd7ecb758de04370", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/scenario/notes.md": "0d48feab03cdd1f71ae276a59da9d93ac9347bffb1620cda1984b587d5c0cb98", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/scenario/record.json": "39e3858efa58028493ce5bd6ec7f4e66215eda34668304fee98934b2d7acdaf7", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/scenario/source.md": "f4dd9f2c103d01f810bf274e9eac3a78058a68ba14308909b10fa5530a9a03bc", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/task.json": "526de760419662a0753c94f18f44bfbb24e9751bb945c8def803f159aca023b5", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/task.json": "8b7b8c9d319ee91d66a4768cbddacccf043991f1c415f9ebc20c87a5997286ee", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/task.toml": "5fe50af779fef25b75aa9ccbaa05302d9d058972bc99354c603e68ab3a4fdbfe", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/task.toml": "5b1528230e33837fb09ef0d3a6a6576004ff2870f7342862340547cc82986faa", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/expected.json": "6beb34dd92c15f80046f8dd13ecd1ff483d2c515ac3c383e5464f4d8359e081d", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/scenario/episode.yaml": "d2b3df2e1a86f26df105d3ee6c79b131ab3e525eb0bb1fb2cd7ecb758de04370", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/scenario/notes.md": "0d48feab03cdd1f71ae276a59da9d93ac9347bffb1620cda1984b587d5c0cb98", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/scenario/record.json": "39e3858efa58028493ce5bd6ec7f4e66215eda34668304fee98934b2d7acdaf7", @@ -198,30 +202,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/docker-compose.yaml": "584e09718288cfcdf8a842221bd0e3e465fe99a18277754f582dcab809deb23a", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/scenario/episode.yaml": "d2b3df2e1a86f26df105d3ee6c79b131ab3e525eb0bb1fb2cd7ecb758de04370", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/scenario/notes.md": "0d48feab03cdd1f71ae276a59da9d93ac9347bffb1620cda1984b587d5c0cb98", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/scenario/record.json": "39e3858efa58028493ce5bd6ec7f4e66215eda34668304fee98934b2d7acdaf7", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/scenario/source.md": "f4dd9f2c103d01f810bf274e9eac3a78058a68ba14308909b10fa5530a9a03bc", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/task.json": "2b7c46608e2d65cca60d51bc840c7e1830ac7047cd3a0a18a2c4974481c2460b", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/task.json": "e47c7f9abbfc021304a3d3dab8b46cd8bcd78a61620e9b0f4899864096bc6c25", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/task.toml": "32aa1947432c9e487283e6890bcabe68bb626c06b9fb06be63e993ca3bb2aa57", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/task.toml": "b1334da36ee96f23c8faa3f2ad68979ae476489bbf75ef1a9e72801f075fad74", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/expected.json": "0f012648faa25afb3513b8a8c2ba3fea18c7fb797c9c02c44fbceae20948aca5", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/scenario/episode.yaml": "d2b3df2e1a86f26df105d3ee6c79b131ab3e525eb0bb1fb2cd7ecb758de04370", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/scenario/notes.md": "0d48feab03cdd1f71ae276a59da9d93ac9347bffb1620cda1984b587d5c0cb98", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/scenario/record.json": "39e3858efa58028493ce5bd6ec7f4e66215eda34668304fee98934b2d7acdaf7", @@ -240,30 +244,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/docker-compose.yaml": "359452f1a4f5b1bbc2e689b21def4d0bb1e41dab0ed88e8343b0bee7d496bc80", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/team/scenario/episode.yaml": "d2b3df2e1a86f26df105d3ee6c79b131ab3e525eb0bb1fb2cd7ecb758de04370", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/team/scenario/notes.md": "0d48feab03cdd1f71ae276a59da9d93ac9347bffb1620cda1984b587d5c0cb98", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/team/scenario/record.json": "39e3858efa58028493ce5bd6ec7f4e66215eda34668304fee98934b2d7acdaf7", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/team/scenario/source.md": "f4dd9f2c103d01f810bf274e9eac3a78058a68ba14308909b10fa5530a9a03bc", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/team/task.json": "6279ee899aab8bf24777184ae8fb96f4a257f2f617ad4e05e7241b23a5b00627", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/team/task.json": "27b543f08e0be4b33abd8d4d6d39320b26de48d57c3de005aca32aa1d808a19e", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/task.toml": "cbaa1210d42c92aa48cb046b93230090b00974995c727ce2b1edabfb1f5e5174", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/task.toml": "9c40e61e8c2ceed8436f809a84c38ff16e219cd647fd8c0b0b93ab8dd8e48569", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/tests/expected.json": "6a09a551e29e566506c059c0be0ac98ab97423ed6859a6f95030bd0870f241d3", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/tests/scenario/episode.yaml": "d2b3df2e1a86f26df105d3ee6c79b131ab3e525eb0bb1fb2cd7ecb758de04370", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/tests/scenario/notes.md": "0d48feab03cdd1f71ae276a59da9d93ac9347bffb1620cda1984b587d5c0cb98", "tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/tests/scenario/record.json": "39e3858efa58028493ce5bd6ec7f4e66215eda34668304fee98934b2d7acdaf7", @@ -282,30 +286,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/docker-compose.yaml": "b276c08be55b7739f3d4a136322517362a06454023d7295b7db7fa8fc9181a9b", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/team/scenario/episode.yaml": "3f92bd49054fe96208b646174d4f3c90b43c2f5a0b38da0d4935e63c3bd35db9", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/team/scenario/notes.md": "9cfb8fe457579bafd012689aaae87f6c41cefc6959b2ff3814943716661ee44c", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/team/scenario/record.json": "aa28686fd0f31a8c4091053b54794e16f90524624ea205553db57bcc2bbf4111", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/team/scenario/source.md": "9e7aff6c5dcb4f966f2a9700df174f4435ff0794634802b54872ffc6096fe5b3", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/team/task.json": "7dae1683b831197e2322be0b4652bf55736da04115034698a3b4f2e96ee35960", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/team/task.json": "5b2badc759366c6eda086b7630820ff4bd286ac1949412687218851a97b9de76", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/task.toml": "5f5ba05ed41d68ad9d87ee4a7f7b72cf59216504027c6bc947c85894976090bd", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/task.toml": "8210a3d7be6c9e186674eb80941b8ce30874eadc29c041dac2fbb885a4611bb8", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/tests/expected.json": "873e72180f7d2ef47ff5fd174a369a0ff40cd6aea3bc950b176d6a060790e21e", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/tests/scenario/episode.yaml": "3f92bd49054fe96208b646174d4f3c90b43c2f5a0b38da0d4935e63c3bd35db9", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/tests/scenario/notes.md": "9cfb8fe457579bafd012689aaae87f6c41cefc6959b2ff3814943716661ee44c", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/tests/scenario/record.json": "aa28686fd0f31a8c4091053b54794e16f90524624ea205553db57bcc2bbf4111", @@ -324,30 +328,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/docker-compose.yaml": "7162e65b00c85b2aea29c381058d72736ecc3a8c8b3a8c016ab705a8880f9c61", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/team/scenario/episode.yaml": "3f92bd49054fe96208b646174d4f3c90b43c2f5a0b38da0d4935e63c3bd35db9", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/team/scenario/notes.md": "9cfb8fe457579bafd012689aaae87f6c41cefc6959b2ff3814943716661ee44c", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/team/scenario/record.json": "aa28686fd0f31a8c4091053b54794e16f90524624ea205553db57bcc2bbf4111", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/team/scenario/source.md": "9e7aff6c5dcb4f966f2a9700df174f4435ff0794634802b54872ffc6096fe5b3", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/team/task.json": "779eb8214d7e417937e36fae33f013c0b8953fe6fd8e975898775997847f70d9", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/team/task.json": "c1d6abc6f1cffa871d9a01f5bf2d754804e4b2f767d9731484ccbdcc66e48fc1", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/task.toml": "28b6515d2549fc2ab19048e4432a086e8666600476660410832ec97d67e79cd9", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/task.toml": "5ecdbf14e1c1929a67ceb28dd4437e78f5d1b22d0b7a4776bc4724700dda0fe0", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/tests/expected.json": "09886a24c51818aca1cb388bfbc2e11ce13eeb63e5fa26596ffb80d591d44990", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/tests/scenario/episode.yaml": "3f92bd49054fe96208b646174d4f3c90b43c2f5a0b38da0d4935e63c3bd35db9", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/tests/scenario/notes.md": "9cfb8fe457579bafd012689aaae87f6c41cefc6959b2ff3814943716661ee44c", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/tests/scenario/record.json": "aa28686fd0f31a8c4091053b54794e16f90524624ea205553db57bcc2bbf4111", @@ -366,30 +370,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/docker-compose.yaml": "bc087891c3505389c7197fe9512dec6e49e26454d5466adc63119df18f13327b", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/team/scenario/episode.yaml": "3f92bd49054fe96208b646174d4f3c90b43c2f5a0b38da0d4935e63c3bd35db9", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/team/scenario/notes.md": "9cfb8fe457579bafd012689aaae87f6c41cefc6959b2ff3814943716661ee44c", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/team/scenario/record.json": "aa28686fd0f31a8c4091053b54794e16f90524624ea205553db57bcc2bbf4111", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/team/scenario/source.md": "9e7aff6c5dcb4f966f2a9700df174f4435ff0794634802b54872ffc6096fe5b3", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/team/task.json": "a987583fd7cbb1d36605b0bf5bd4714650422f9de5831410164640cb5d3ecff4", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/team/task.json": "f1029b9329e30dd9e9ae16a8f3b372e5d3f218fdd98022281a5fd33864a62d46", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/task.toml": "250eeb975958085049507e54722f93d1ab96358bb636da6d108830f41a4233c1", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/task.toml": "ecf9a78cbd2586f45c92745ef4da21a7987e587f20c59a6a94a7dcede3e21afb", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/tests/expected.json": "f54491fb46fa23f09ee4898f4ac78d84c53d0b7554c1815e4ae191963a08a0d2", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/tests/scenario/episode.yaml": "3f92bd49054fe96208b646174d4f3c90b43c2f5a0b38da0d4935e63c3bd35db9", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/tests/scenario/notes.md": "9cfb8fe457579bafd012689aaae87f6c41cefc6959b2ff3814943716661ee44c", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/tests/scenario/record.json": "aa28686fd0f31a8c4091053b54794e16f90524624ea205553db57bcc2bbf4111", @@ -408,30 +412,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/docker-compose.yaml": "56ff99d32af9b13ab24676a81948a85c30ef534e891c8a087f61903cab67c87a", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/team/scenario/episode.yaml": "3f92bd49054fe96208b646174d4f3c90b43c2f5a0b38da0d4935e63c3bd35db9", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/team/scenario/notes.md": "9cfb8fe457579bafd012689aaae87f6c41cefc6959b2ff3814943716661ee44c", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/team/scenario/record.json": "aa28686fd0f31a8c4091053b54794e16f90524624ea205553db57bcc2bbf4111", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/team/scenario/source.md": "9e7aff6c5dcb4f966f2a9700df174f4435ff0794634802b54872ffc6096fe5b3", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/team/task.json": "01a800cec9efacd6697286c22327ae75ab5fdc607c114f41d3faf0f96a1f5906", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/team/task.json": "ccfd8a9b76494583531be057777515b03622dc2df936f06f7eab2221ab4bdf94", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/task.toml": "32ace154088c6f266ffbb1344d4d27982743df12ad28334499b2c102b7257454", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/task.toml": "0b0ab51adb080c30e498bb06b8610e86757f6f91eb5df637366f1bbeb336d5c3", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/tests/expected.json": "7296f949ce4c7ef34545425a2816ba1f5046421f91fea2e7fb15de8ce6731717", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/tests/scenario/episode.yaml": "3f92bd49054fe96208b646174d4f3c90b43c2f5a0b38da0d4935e63c3bd35db9", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/tests/scenario/notes.md": "9cfb8fe457579bafd012689aaae87f6c41cefc6959b2ff3814943716661ee44c", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/tests/scenario/record.json": "aa28686fd0f31a8c4091053b54794e16f90524624ea205553db57bcc2bbf4111", @@ -450,30 +454,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/docker-compose.yaml": "b595e134976e6572a9aa25a85d0090167dcdc961782d446f6802a931df04182e", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/team/scenario/episode.yaml": "3f92bd49054fe96208b646174d4f3c90b43c2f5a0b38da0d4935e63c3bd35db9", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/team/scenario/notes.md": "9cfb8fe457579bafd012689aaae87f6c41cefc6959b2ff3814943716661ee44c", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/team/scenario/record.json": "aa28686fd0f31a8c4091053b54794e16f90524624ea205553db57bcc2bbf4111", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/team/scenario/source.md": "9e7aff6c5dcb4f966f2a9700df174f4435ff0794634802b54872ffc6096fe5b3", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/team/task.json": "666b510608b9b63b8d08a86161ffd016bd538886c8da4a46e1b66e98ef88873f", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/team/task.json": "de69ab94a937b87b607b835b62b92f7642f61c06cfb642d05217b9f8f920a305", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/task.toml": "0c1488152b42e3d01d4ab1a388fa37c7a52cda2ddd4ee6afb8c318993cd98e6f", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/task.toml": "f8f22da6f82421f778f467d400f34e19be83479bc1cee74a3964a94fc52e6bc3", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/tests/expected.json": "59d3cc02cbcb63afce8bc8b0ea03fc360c85d20d73726d3072b7a4464e0f1bcb", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/tests/scenario/episode.yaml": "3f92bd49054fe96208b646174d4f3c90b43c2f5a0b38da0d4935e63c3bd35db9", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/tests/scenario/notes.md": "9cfb8fe457579bafd012689aaae87f6c41cefc6959b2ff3814943716661ee44c", "tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/tests/scenario/record.json": "aa28686fd0f31a8c4091053b54794e16f90524624ea205553db57bcc2bbf4111", @@ -492,30 +496,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/docker-compose.yaml": "cfaed80f2f5baf6d3c6b0fd8b6ee37d72dc5e3fbaebc9c2e084201aa2188aa8f", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/team/scenario/episode.yaml": "43b4d77e54329045ecc31ed2b9d647645517f2edfa38b1de4ee2c8a70f1e8361", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/team/scenario/notes.md": "9798b2b803aa11cf1f69134da389a590a5f726460c529a101184cb93a70b214b", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/team/scenario/record.json": "4120817904c87744a37d05c45fda2ccb2d0160b0d94176f934140ff40de015f8", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/team/scenario/source.md": "c97c9f719f14f24a14debcf4aba62994ccbbd161e439b4a8b590165ab604d7e3", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/team/task.json": "09e80d015f0d7b09aad719583fc16fb5c8da887c79daeada85087f595832b4f9", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/team/task.json": "3a12ed2b3beb92695d7104010930bbe93d47a2edec0dcf8c07d327f3dc285a9d", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/task.toml": "848ca8c2d366794100d3dfadf3ead0e069fd2519decd38e04e11c17d1fb8ca95", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/task.toml": "dddc72d5ee9e039eec80e3dc67aa6d9d00169ce0ec187a1cbb14c02a8f8a5683", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/tests/expected.json": "63dcd1a6b107d57fd84250c678f6c466beacbec2e2b5ecc0041c3a80548a8838", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/tests/scenario/episode.yaml": "43b4d77e54329045ecc31ed2b9d647645517f2edfa38b1de4ee2c8a70f1e8361", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/tests/scenario/notes.md": "9798b2b803aa11cf1f69134da389a590a5f726460c529a101184cb93a70b214b", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/tests/scenario/record.json": "4120817904c87744a37d05c45fda2ccb2d0160b0d94176f934140ff40de015f8", @@ -534,30 +538,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/docker-compose.yaml": "7859fd06dc68c2d7380a6c32287611a180b0620ebe75a36850ea2602d5a5f267", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/team/scenario/episode.yaml": "43b4d77e54329045ecc31ed2b9d647645517f2edfa38b1de4ee2c8a70f1e8361", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/team/scenario/notes.md": "9798b2b803aa11cf1f69134da389a590a5f726460c529a101184cb93a70b214b", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/team/scenario/record.json": "4120817904c87744a37d05c45fda2ccb2d0160b0d94176f934140ff40de015f8", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/team/scenario/source.md": "c97c9f719f14f24a14debcf4aba62994ccbbd161e439b4a8b590165ab604d7e3", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/team/task.json": "61af9dea8724b760bb6cde0b49ba48e5cd55cf0ab7dc7794c2ddb2a191ddf076", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/team/task.json": "0a3b118711982d197e36846b1a998e92837764c1c1cbd740eda64d9fd72437f7", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/task.toml": "a7edeca54e4a9f79bf65e99bb40f15141ebd6abe9d7c5c2a4d7ace19db45c916", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/task.toml": "4f43fc4f1d0353a43ceab4aecb2f0a0baf3a869ed0c50c3acdb1f3d9bd8e8058", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/tests/expected.json": "3cb343b1d4887842359d7ccbd91d2f64d3216b5d3d3103ec0bc5bf6cc778fb8a", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/tests/scenario/episode.yaml": "43b4d77e54329045ecc31ed2b9d647645517f2edfa38b1de4ee2c8a70f1e8361", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/tests/scenario/notes.md": "9798b2b803aa11cf1f69134da389a590a5f726460c529a101184cb93a70b214b", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/tests/scenario/record.json": "4120817904c87744a37d05c45fda2ccb2d0160b0d94176f934140ff40de015f8", @@ -576,30 +580,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/docker-compose.yaml": "46789e45a267f0390cbff1dbc66fc7fbe0636394177bf210f4b1579372252a5d", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/team/scenario/episode.yaml": "43b4d77e54329045ecc31ed2b9d647645517f2edfa38b1de4ee2c8a70f1e8361", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/team/scenario/notes.md": "9798b2b803aa11cf1f69134da389a590a5f726460c529a101184cb93a70b214b", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/team/scenario/record.json": "4120817904c87744a37d05c45fda2ccb2d0160b0d94176f934140ff40de015f8", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/team/scenario/source.md": "c97c9f719f14f24a14debcf4aba62994ccbbd161e439b4a8b590165ab604d7e3", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/team/task.json": "580f71da3d1974f528db93b2121f162a23786f835a6420d82b94fac7e0dc11c3", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/team/task.json": "d8649d3dbdadc761d6af75e1b2e9b9cd9f87ce10b344a666d1201b0f2ffaeca3", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/task.toml": "3594afd7fa5bb81a7d7a13f62a13bf892601646314a0bd14b91cdd3c31360f3f", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/task.toml": "af99193d260bb164c6c7f6229bcb5f9a2b16d361215e4d48f9065c8cca3e0366", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/tests/expected.json": "74bd83c0c1bf214c45506b185db5a185fb4868b1d7c1d69847f0cbeb6189fc96", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/tests/scenario/episode.yaml": "43b4d77e54329045ecc31ed2b9d647645517f2edfa38b1de4ee2c8a70f1e8361", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/tests/scenario/notes.md": "9798b2b803aa11cf1f69134da389a590a5f726460c529a101184cb93a70b214b", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/tests/scenario/record.json": "4120817904c87744a37d05c45fda2ccb2d0160b0d94176f934140ff40de015f8", @@ -618,30 +622,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/docker-compose.yaml": "3fac63ab3c39144dfd5f9fb7ebebf46c0190115cedf553eec8b2fe06e25dec57", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/team/scenario/episode.yaml": "43b4d77e54329045ecc31ed2b9d647645517f2edfa38b1de4ee2c8a70f1e8361", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/team/scenario/notes.md": "9798b2b803aa11cf1f69134da389a590a5f726460c529a101184cb93a70b214b", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/team/scenario/record.json": "4120817904c87744a37d05c45fda2ccb2d0160b0d94176f934140ff40de015f8", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/team/scenario/source.md": "c97c9f719f14f24a14debcf4aba62994ccbbd161e439b4a8b590165ab604d7e3", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/team/task.json": "cc8a6554f25aae6585e8ce5495ac39a9d1d571163939ccb8a0f2677d0a5c5363", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/team/task.json": "7fa5e6a14bc03d41f08e5f7e1c438ffb9575222afd178ff21351e833253ed03a", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/task.toml": "1d9a88e11e3dea36eb4261b8595cd7fc65c1e6892d299d411e38fb748a4ed772", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/task.toml": "be2673e0dbce7246b6b26b6f515961917286e2d6fa63bbaab12f3110ac3bd0b5", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/tests/expected.json": "0198e16c43ef0845a217fedc55aa0471efb1528d98b9bc4d3e59dc1b4ee3cc09", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/tests/scenario/episode.yaml": "43b4d77e54329045ecc31ed2b9d647645517f2edfa38b1de4ee2c8a70f1e8361", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/tests/scenario/notes.md": "9798b2b803aa11cf1f69134da389a590a5f726460c529a101184cb93a70b214b", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/tests/scenario/record.json": "4120817904c87744a37d05c45fda2ccb2d0160b0d94176f934140ff40de015f8", @@ -660,30 +664,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/docker-compose.yaml": "2212162b6159134733bf97af201d14423bbbae961ac8693fdd7aaa36575a4e1e", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/team/scenario/episode.yaml": "43b4d77e54329045ecc31ed2b9d647645517f2edfa38b1de4ee2c8a70f1e8361", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/team/scenario/notes.md": "9798b2b803aa11cf1f69134da389a590a5f726460c529a101184cb93a70b214b", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/team/scenario/record.json": "4120817904c87744a37d05c45fda2ccb2d0160b0d94176f934140ff40de015f8", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/team/scenario/source.md": "c97c9f719f14f24a14debcf4aba62994ccbbd161e439b4a8b590165ab604d7e3", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/team/task.json": "c2ac70fff66526303423cb8b03a2267e32855be5b168339e967b797ad79f8a93", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/team/task.json": "70efe3ed9d8eaf910b438bbfa34e768946665c2da58dc6b2d6d98be8dc024fc5", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/task.toml": "5179a37d3222a4efffa5caa3d492276e6fd92cdf70b7a3c05875a3d9416a3b42", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/task.toml": "a1be5fbe119bd2f6a58beb65c2a59827e850b5e7e2a65b58474e3a76fec99bbf", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/tests/expected.json": "d0de251abf93b6b040a9fe681d7acb7f9024e46b6e344c7d9059fe15e124052a", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/tests/scenario/episode.yaml": "43b4d77e54329045ecc31ed2b9d647645517f2edfa38b1de4ee2c8a70f1e8361", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/tests/scenario/notes.md": "9798b2b803aa11cf1f69134da389a590a5f726460c529a101184cb93a70b214b", "tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/tests/scenario/record.json": "4120817904c87744a37d05c45fda2ccb2d0160b0d94176f934140ff40de015f8", @@ -702,30 +706,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/docker-compose.yaml": "905d193af384d10645b144cca72a45e49b738850af6016c55d15d19b053a7710", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/team/scenario/episode.yaml": "1478f53347e23a47e35ff14e399933078fe4445734dd2c7ebb7036bd8e59074e", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/team/scenario/notes.md": "3dc54691819b26d880e49d3f74fcd294bec669429bdbad61566e890b4e09ca4b", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/team/scenario/record.json": "8b0c5712cd8c4e7c91dd5617687f4b0c7218d288ef0ab43a7b718ec8860a87aa", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/team/scenario/source.md": "4db0af16045263ca271f766247bb1ed66868e6a88aefb95fd78cb0feba72ec96", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/team/task.json": "65d0aa0c73dc3258556182f3a32c04ddd154d318f88ddaf170ae3729c95c997d", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/team/task.json": "6a43fef80c43e5f739f82993893100672e3926f0505ec55a03d5a95e4bd6c21d", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/task.toml": "ed6e638cc1f3bb02348cf9abfbfb3813cd99cb18398c6cac6f8f79957efefe3c", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/task.toml": "556b8975e18b1f575010d29a7e58ed7d5f77bca7ba02dec34c77a266b938b583", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/tests/expected.json": "b3b7d87992ce08f8ad8ff54b13b5c8e1106e95d5070bbffa7589a1d4536ec207", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/tests/scenario/episode.yaml": "1478f53347e23a47e35ff14e399933078fe4445734dd2c7ebb7036bd8e59074e", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/tests/scenario/notes.md": "3dc54691819b26d880e49d3f74fcd294bec669429bdbad61566e890b4e09ca4b", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/tests/scenario/record.json": "8b0c5712cd8c4e7c91dd5617687f4b0c7218d288ef0ab43a7b718ec8860a87aa", @@ -744,30 +748,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/docker-compose.yaml": "12bff02db2d9635dc1ac17f75523c19f6c832b15bc43bab0cdbafe6ea44c9a51", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/team/scenario/episode.yaml": "1478f53347e23a47e35ff14e399933078fe4445734dd2c7ebb7036bd8e59074e", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/team/scenario/notes.md": "3dc54691819b26d880e49d3f74fcd294bec669429bdbad61566e890b4e09ca4b", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/team/scenario/record.json": "8b0c5712cd8c4e7c91dd5617687f4b0c7218d288ef0ab43a7b718ec8860a87aa", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/team/scenario/source.md": "4db0af16045263ca271f766247bb1ed66868e6a88aefb95fd78cb0feba72ec96", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/team/task.json": "0a88941ece33b78ae0df747b816a0dc7305322159b96c85def5f4ba4d2eb9dd8", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/team/task.json": "0515c4349523abe98cff49e490d2098232053bfa83ad0db68bb81d17865b2c03", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/task.toml": "3862b7713bdcd482beb1017f56fa6ab98ccf3f47d96499db7afef933bb5f6632", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/task.toml": "4a789d72c2ece59689322c7b5b825750098cd80891b45d77c655cfdccafb52b7", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/tests/expected.json": "1574b5cc509cb0bf142e831fe7c8afc33e0734b99c8ce8fac392973ca485ddca", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/tests/scenario/episode.yaml": "1478f53347e23a47e35ff14e399933078fe4445734dd2c7ebb7036bd8e59074e", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/tests/scenario/notes.md": "3dc54691819b26d880e49d3f74fcd294bec669429bdbad61566e890b4e09ca4b", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/tests/scenario/record.json": "8b0c5712cd8c4e7c91dd5617687f4b0c7218d288ef0ab43a7b718ec8860a87aa", @@ -786,30 +790,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/docker-compose.yaml": "1b7323b6f167d3e606393cc44312bb8f9bddf5c8130e9f5b48bbde83b0a059c0", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/team/scenario/episode.yaml": "1478f53347e23a47e35ff14e399933078fe4445734dd2c7ebb7036bd8e59074e", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/team/scenario/notes.md": "3dc54691819b26d880e49d3f74fcd294bec669429bdbad61566e890b4e09ca4b", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/team/scenario/record.json": "8b0c5712cd8c4e7c91dd5617687f4b0c7218d288ef0ab43a7b718ec8860a87aa", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/team/scenario/source.md": "4db0af16045263ca271f766247bb1ed66868e6a88aefb95fd78cb0feba72ec96", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/team/task.json": "ddeeb1679d3480c00d7bb5f6f81ac984f9eb85dfc5409aa42825c96afb8210e5", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/team/task.json": "44553e895f458d88f389fbbe1d8ce992404caa5e91ad7ba4033910cfe7ed919a", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/task.toml": "e9a361e27bad56b03af3c93bd7d87573af06bc7e0b67db9d6420496402887a8b", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/task.toml": "70bc76a4b4d462b11c756a9ea5fd818f01f7479da62cb759e52b32a13d169fa1", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/tests/expected.json": "13f4ee73f07041ec4149a3b700d31a9940e245c3d572029d697c38081602cf73", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/tests/scenario/episode.yaml": "1478f53347e23a47e35ff14e399933078fe4445734dd2c7ebb7036bd8e59074e", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/tests/scenario/notes.md": "3dc54691819b26d880e49d3f74fcd294bec669429bdbad61566e890b4e09ca4b", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/tests/scenario/record.json": "8b0c5712cd8c4e7c91dd5617687f4b0c7218d288ef0ab43a7b718ec8860a87aa", @@ -828,30 +832,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/docker-compose.yaml": "99eb44d5e41d64724ae8311a2f49e6ca116fb1cb348f69eff1e2a64cad7cb59f", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/team/scenario/episode.yaml": "1478f53347e23a47e35ff14e399933078fe4445734dd2c7ebb7036bd8e59074e", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/team/scenario/notes.md": "3dc54691819b26d880e49d3f74fcd294bec669429bdbad61566e890b4e09ca4b", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/team/scenario/record.json": "8b0c5712cd8c4e7c91dd5617687f4b0c7218d288ef0ab43a7b718ec8860a87aa", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/team/scenario/source.md": "4db0af16045263ca271f766247bb1ed66868e6a88aefb95fd78cb0feba72ec96", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/team/task.json": "d05869f0ab26388752538775ee48019c9f00362c084b3827ebf60ec9b0622490", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/team/task.json": "a60d30fb3433bae285d19fed0c710605cb90c5a9fa3b78153cae85ad125e1035", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/task.toml": "f9a09500963ea366db8b0b15ebcc39f16d0ba078006217178ce8f265b1460606", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/task.toml": "36574c681f5713ea7aacbade2d183bedea3ee98f8c51692e1d8e1eff358daada", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/tests/expected.json": "274a3ecfc8c1b902e41691b27b71e045175661537e55881e02765cb9e74df5e9", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/tests/scenario/episode.yaml": "1478f53347e23a47e35ff14e399933078fe4445734dd2c7ebb7036bd8e59074e", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/tests/scenario/notes.md": "3dc54691819b26d880e49d3f74fcd294bec669429bdbad61566e890b4e09ca4b", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/tests/scenario/record.json": "8b0c5712cd8c4e7c91dd5617687f4b0c7218d288ef0ab43a7b718ec8860a87aa", @@ -870,30 +874,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/docker-compose.yaml": "c3a6a4dfd62dc70ec896f06a9440dd7bf8e19454c2747ec9d7c57dce384c7e2d", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/team/scenario/episode.yaml": "1478f53347e23a47e35ff14e399933078fe4445734dd2c7ebb7036bd8e59074e", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/team/scenario/notes.md": "3dc54691819b26d880e49d3f74fcd294bec669429bdbad61566e890b4e09ca4b", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/team/scenario/record.json": "8b0c5712cd8c4e7c91dd5617687f4b0c7218d288ef0ab43a7b718ec8860a87aa", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/team/scenario/source.md": "4db0af16045263ca271f766247bb1ed66868e6a88aefb95fd78cb0feba72ec96", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/team/task.json": "c51f25cbd9a2db2ddff63374faf6984be9aec870c5d6d3485a2a1fbb4ffd286c", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/team/task.json": "3e3c117ce5b0e07bd4434f32ab9725c54d89cd9040036a0c30b0919b76a9c3c3", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/task.toml": "09b8d437649200b0ad1c10ea44f2c7083ccb6d1d968499a92e6b468e879d3ee4", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/task.toml": "991e69316fd93e2035a5c884a355072f27f434aca66cf736ce1f9f0754be306b", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/tests/expected.json": "abaa9279084b46521d87d9b273dbeaf0e50de049971a6fc2316355b9f6f59a7c", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/tests/scenario/episode.yaml": "1478f53347e23a47e35ff14e399933078fe4445734dd2c7ebb7036bd8e59074e", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/tests/scenario/notes.md": "3dc54691819b26d880e49d3f74fcd294bec669429bdbad61566e890b4e09ca4b", "tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/tests/scenario/record.json": "8b0c5712cd8c4e7c91dd5617687f4b0c7218d288ef0ab43a7b718ec8860a87aa", @@ -912,30 +916,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/docker-compose.yaml": "27df58218e62cc54eb3996eb7371e0b78875f16b7e81a419bc7e7f7f0c7fc2e4", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/team/scenario/episode.yaml": "299691fbf4430c46e27bd65ab3cc3044062092212034d3ddd78387ff785a7681", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/team/scenario/notes.md": "dfd8cea82ff5a35dfd69ed8ad12f59b0a7e667f80fa187474455bf1b305e58c0", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/team/scenario/record.json": "bca170df1922d7f603112c2aa9de768d1d8c30211c3991814bebe4bb0e5f4855", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/team/scenario/source.md": "2facf12d8eb02125d028b0ed0339109b55af57b8a098009cfe9a2a60d66caa55", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/team/task.json": "8e3eeaf677e64b8a0b7449bcc2d3965c08c3d3f28a0b80f5a78278b17f1b4a3a", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/team/task.json": "9648c7f281256edb6980d165e06bb1949bb5beb3cab693f74db2392a72e32687", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/task.toml": "93572a5f998215f7c64110f1795ccfd16c1ed096125adae64442fbc51262a678", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/task.toml": "809c3cd3b962b2799634ddb08cd841f6fb87209ab21d139d977ce328f87cc4e1", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/tests/expected.json": "8be3698c018ade044fa0d089aaa56d4057d33e1a51ca5244b285030a53089a00", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/tests/scenario/episode.yaml": "299691fbf4430c46e27bd65ab3cc3044062092212034d3ddd78387ff785a7681", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/tests/scenario/notes.md": "dfd8cea82ff5a35dfd69ed8ad12f59b0a7e667f80fa187474455bf1b305e58c0", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/tests/scenario/record.json": "bca170df1922d7f603112c2aa9de768d1d8c30211c3991814bebe4bb0e5f4855", @@ -954,30 +958,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/docker-compose.yaml": "832428c55854a49a3a28df78518e58522b868d0512d3b180d9fc73cdde215db1", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/team/scenario/episode.yaml": "299691fbf4430c46e27bd65ab3cc3044062092212034d3ddd78387ff785a7681", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/team/scenario/notes.md": "dfd8cea82ff5a35dfd69ed8ad12f59b0a7e667f80fa187474455bf1b305e58c0", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/team/scenario/record.json": "bca170df1922d7f603112c2aa9de768d1d8c30211c3991814bebe4bb0e5f4855", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/team/scenario/source.md": "2facf12d8eb02125d028b0ed0339109b55af57b8a098009cfe9a2a60d66caa55", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/team/task.json": "0af56f2144d238815fb9786d86d3bc407c2510c501efe613fad70d5bce59ca7f", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/team/task.json": "6399b0406149d788ca06594082ea69366064e83da5ede602a2cfdb5c71f6b3fa", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/task.toml": "b5fa3ebe2fec641ac8ebc8cfe02cca11044f1fe121ea6743f7d1dfbc4909b929", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/task.toml": "d67196761703ea794644a8e5322627ec8704f180ba04e6c992e8f976310b79d2", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/tests/expected.json": "2fa38eb86b6baf1c4c2752bc15dd7f9274a17991eb314ea83a4f26f041c2606c", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/tests/scenario/episode.yaml": "299691fbf4430c46e27bd65ab3cc3044062092212034d3ddd78387ff785a7681", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/tests/scenario/notes.md": "dfd8cea82ff5a35dfd69ed8ad12f59b0a7e667f80fa187474455bf1b305e58c0", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/tests/scenario/record.json": "bca170df1922d7f603112c2aa9de768d1d8c30211c3991814bebe4bb0e5f4855", @@ -996,30 +1000,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/docker-compose.yaml": "4d929c58c8ad93084e6d25b6283907b42ef9e888a5d02581427cac2ce3db7cda", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/team/scenario/episode.yaml": "299691fbf4430c46e27bd65ab3cc3044062092212034d3ddd78387ff785a7681", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/team/scenario/notes.md": "dfd8cea82ff5a35dfd69ed8ad12f59b0a7e667f80fa187474455bf1b305e58c0", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/team/scenario/record.json": "bca170df1922d7f603112c2aa9de768d1d8c30211c3991814bebe4bb0e5f4855", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/team/scenario/source.md": "2facf12d8eb02125d028b0ed0339109b55af57b8a098009cfe9a2a60d66caa55", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/team/task.json": "5388a8f37fbacddec553819230dd2d37ff726bd6b810fb520afa422198bb3b40", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/team/task.json": "33f6b2ba5799e4bbbf143628ea949575091af203abc7ebe5b7161192f563177f", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/task.toml": "f7ea9d2081190052f09bd22f07772540b3abac5be9847a2e172c75eb010ccf88", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/task.toml": "4056e626a490bfc229b34ff11834face5e98b7541e35dcb8e71a2b67f08051c9", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/tests/expected.json": "f8b422d3f5066dc8fe8b44f534315e5de9be1910d9598ecd56cb713360fca283", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/tests/scenario/episode.yaml": "299691fbf4430c46e27bd65ab3cc3044062092212034d3ddd78387ff785a7681", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/tests/scenario/notes.md": "dfd8cea82ff5a35dfd69ed8ad12f59b0a7e667f80fa187474455bf1b305e58c0", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/tests/scenario/record.json": "bca170df1922d7f603112c2aa9de768d1d8c30211c3991814bebe4bb0e5f4855", @@ -1038,30 +1042,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/docker-compose.yaml": "227f712077d340a759a305e90059c1bc60a496ece8592537af85fe15dc13289c", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/team/scenario/episode.yaml": "299691fbf4430c46e27bd65ab3cc3044062092212034d3ddd78387ff785a7681", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/team/scenario/notes.md": "dfd8cea82ff5a35dfd69ed8ad12f59b0a7e667f80fa187474455bf1b305e58c0", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/team/scenario/record.json": "bca170df1922d7f603112c2aa9de768d1d8c30211c3991814bebe4bb0e5f4855", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/team/scenario/source.md": "2facf12d8eb02125d028b0ed0339109b55af57b8a098009cfe9a2a60d66caa55", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/team/task.json": "c2c3c14e53df95cf0d2eddab605764172f08c2f52b72e582fc446ab58de89b36", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/team/task.json": "28aa281d53c4e6f61798e00cfe827782c2c2fe5440285e2109591d83007b1b9a", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/task.toml": "e51f8b3e4ebba7a3456dbee077269a28a9e7a6561bd9252850b69fdf7ad904a7", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/task.toml": "c19b0e7e4b57aaf01acfee011aeddee8fdbdd10671cbd602e421d2555d55a800", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/tests/expected.json": "ee34282281139a2b3f6d8f15332b8082fac4f18f5275b07ab3fae8e72f3f8bea", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/tests/scenario/episode.yaml": "299691fbf4430c46e27bd65ab3cc3044062092212034d3ddd78387ff785a7681", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/tests/scenario/notes.md": "dfd8cea82ff5a35dfd69ed8ad12f59b0a7e667f80fa187474455bf1b305e58c0", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/tests/scenario/record.json": "bca170df1922d7f603112c2aa9de768d1d8c30211c3991814bebe4bb0e5f4855", @@ -1080,30 +1084,30 @@ "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/docker-compose.yaml": "6adac881f8645f1265fd45f1ff0d5c71de924a09dd12fbb4acdda11717f01b9f", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/team/scenario/episode.yaml": "299691fbf4430c46e27bd65ab3cc3044062092212034d3ddd78387ff785a7681", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/team/scenario/notes.md": "dfd8cea82ff5a35dfd69ed8ad12f59b0a7e667f80fa187474455bf1b305e58c0", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/team/scenario/record.json": "bca170df1922d7f603112c2aa9de768d1d8c30211c3991814bebe4bb0e5f4855", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/team/scenario/source.md": "2facf12d8eb02125d028b0ed0339109b55af57b8a098009cfe9a2a60d66caa55", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/team/task.json": "7e2e9ca4613e8722fe80ffd89da44297c2967c5724c9523fe002d552fc6a5157", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/team/task.json": "8f16170353fcaed99425b946c165c001f7bb019b9c25422e74d0125bea39aeb5", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/task.toml": "5b24c19f47a25d5bb1448cc41d110a84c3b72e5aae0709fb17c23d861de8fbdd", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/task.toml": "6cd4d53a3d25d85f03364df90c30c2180721d75da8a27997aa996aa208f96ef8", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/tests/expected.json": "e263e21224810edf522486529598f6fcad2587f19637e08601d4e8c48f1ea8f4", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/tests/scenario/episode.yaml": "299691fbf4430c46e27bd65ab3cc3044062092212034d3ddd78387ff785a7681", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/tests/scenario/notes.md": "dfd8cea82ff5a35dfd69ed8ad12f59b0a7e667f80fa187474455bf1b305e58c0", "tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/tests/scenario/record.json": "bca170df1922d7f603112c2aa9de768d1d8c30211c3991814bebe4bb0e5f4855", @@ -1122,30 +1126,30 @@ "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/docker-compose.yaml": "478e9122cc5f986169dde869c454ef4525394f7b64faffa589ef60a1bcff9bd3", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/team/scenario/episode.yaml": "f0c27c9226568b5e287a11688a0cf979c04e95b5818bc9a52eb6938555b2135e", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/team/scenario/notes.md": "556d0f07dfbe93d218622c91e33ba4c6e72cb81ce392bf8aff3f992f320a21de", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/team/scenario/record.json": "32c6a5b4a8a5600890f2d6e8f2d1f81f2817a68e3e168c2e579adc835d23f49c", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/team/scenario/source.md": "ab9846f9d6618fffcb07920e88b8550d8a76a374b75afd45ccc11588c9c5d1f5", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/team/task.json": "7d96bd5282809a0bd0b32d9e792269926753ba51aa84b5fc00f06f08edd82847", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/team/task.json": "eb2b4c40eebcd7ef92bda17468709efaaef7f96860df080b8407610a97cc8b69", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/task.toml": "e2aa87415d1050ecc61968fc7d722cab1bdd272a519625956074475d1a77b87d", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/task.toml": "ce3196be69d6d64fcd982b2ced31c80b595ec0f52ed93cc5279f0c5c9afa90a3", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/tests/expected.json": "712b9fe1fbeae952a7fe25317e90ee552906a8926cea3e676ce342aab16b0dae", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/tests/scenario/episode.yaml": "f0c27c9226568b5e287a11688a0cf979c04e95b5818bc9a52eb6938555b2135e", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/tests/scenario/notes.md": "556d0f07dfbe93d218622c91e33ba4c6e72cb81ce392bf8aff3f992f320a21de", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/tests/scenario/record.json": "32c6a5b4a8a5600890f2d6e8f2d1f81f2817a68e3e168c2e579adc835d23f49c", @@ -1164,30 +1168,30 @@ "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/docker-compose.yaml": "f3864e15b01f6473ab97a6c7915247fcc8df66d08a6be6a8f1c386e1e03cec81", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/team/scenario/episode.yaml": "f0c27c9226568b5e287a11688a0cf979c04e95b5818bc9a52eb6938555b2135e", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/team/scenario/notes.md": "556d0f07dfbe93d218622c91e33ba4c6e72cb81ce392bf8aff3f992f320a21de", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/team/scenario/record.json": "32c6a5b4a8a5600890f2d6e8f2d1f81f2817a68e3e168c2e579adc835d23f49c", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/team/scenario/source.md": "ab9846f9d6618fffcb07920e88b8550d8a76a374b75afd45ccc11588c9c5d1f5", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/team/task.json": "7803271bdca6c70b7f4edd848a2d8e929412f6dbb47fcf8d158c001bc8db3909", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/team/task.json": "53af4c1c3f4af878ef94064fcee93b6f89e3eb88ba8e92e0d3067ca00fe920ac", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/task.toml": "c1ad98128e52876e296ec703cfa14e13e9b6cf67dacb3559ec2a647fda4c42f2", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/task.toml": "d6dd3cbe656b137deaba4025c753cea01cf0c2e6b1dce6b0522a2d93dc2b24de", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/tests/expected.json": "c7f17c1fa767a792e6309efd65678e0ed9e1d6cb558a7781e7dc170c6c93f0ba", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/tests/scenario/episode.yaml": "f0c27c9226568b5e287a11688a0cf979c04e95b5818bc9a52eb6938555b2135e", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/tests/scenario/notes.md": "556d0f07dfbe93d218622c91e33ba4c6e72cb81ce392bf8aff3f992f320a21de", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/tests/scenario/record.json": "32c6a5b4a8a5600890f2d6e8f2d1f81f2817a68e3e168c2e579adc835d23f49c", @@ -1206,30 +1210,30 @@ "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/docker-compose.yaml": "849439b006c1c031b4370265ea75c588d8139819550fd1f487d21cc8b02e83e8", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/team/scenario/episode.yaml": "f0c27c9226568b5e287a11688a0cf979c04e95b5818bc9a52eb6938555b2135e", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/team/scenario/notes.md": "556d0f07dfbe93d218622c91e33ba4c6e72cb81ce392bf8aff3f992f320a21de", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/team/scenario/record.json": "32c6a5b4a8a5600890f2d6e8f2d1f81f2817a68e3e168c2e579adc835d23f49c", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/team/scenario/source.md": "ab9846f9d6618fffcb07920e88b8550d8a76a374b75afd45ccc11588c9c5d1f5", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/team/task.json": "24fe4757404077974da7bd6d1e2c68566719526ffb263531c4a215192a0e8d53", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/team/task.json": "4976274c1bb68a84cf569130b3aa0639d7cec454c57e7a9785deed602e4d3194", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/task.toml": "0d46b9f2085126b929c6ac9278dbbaf12b0298fd5826e2555e3a32a04975f303", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/task.toml": "998fa39bdb52addfcb5c2676a302705fb59325b6726700f2ebec62ad911352ae", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/tests/expected.json": "3e0cc586dd827e19e102d19184b86a4a028abed6bd7d7472cff41a64f02b728c", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/tests/scenario/episode.yaml": "f0c27c9226568b5e287a11688a0cf979c04e95b5818bc9a52eb6938555b2135e", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/tests/scenario/notes.md": "556d0f07dfbe93d218622c91e33ba4c6e72cb81ce392bf8aff3f992f320a21de", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/tests/scenario/record.json": "32c6a5b4a8a5600890f2d6e8f2d1f81f2817a68e3e168c2e579adc835d23f49c", @@ -1248,30 +1252,30 @@ "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/docker-compose.yaml": "61406dae234ff164cd0eb05b1284332bd7c9f25177e86c63033c4da70c10d0e3", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/team/scenario/episode.yaml": "f0c27c9226568b5e287a11688a0cf979c04e95b5818bc9a52eb6938555b2135e", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/team/scenario/notes.md": "556d0f07dfbe93d218622c91e33ba4c6e72cb81ce392bf8aff3f992f320a21de", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/team/scenario/record.json": "32c6a5b4a8a5600890f2d6e8f2d1f81f2817a68e3e168c2e579adc835d23f49c", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/team/scenario/source.md": "ab9846f9d6618fffcb07920e88b8550d8a76a374b75afd45ccc11588c9c5d1f5", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/team/task.json": "0da1147c7b371a9c2deeebdce64d49b55ed7db2774880eea5e7be3805ae0aa55", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/team/task.json": "01cf95ae8179fade46260c403773f549150c9abdb2eb9dcc42bf224226c88fa1", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/task.toml": "e22fb619753d645911b9181c40587755ea83e3917ccb9a82851d31077cd45e4e", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/task.toml": "b4c95b8c561680c0818dd7744a4ad9e2beff3881044db9644b46d67009cf9819", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/tests/expected.json": "7fde5533303a1d72675d32c42c8364d406e9950a650ac026453c3b485e705ac5", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/tests/scenario/episode.yaml": "f0c27c9226568b5e287a11688a0cf979c04e95b5818bc9a52eb6938555b2135e", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/tests/scenario/notes.md": "556d0f07dfbe93d218622c91e33ba4c6e72cb81ce392bf8aff3f992f320a21de", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/tests/scenario/record.json": "32c6a5b4a8a5600890f2d6e8f2d1f81f2817a68e3e168c2e579adc835d23f49c", @@ -1290,30 +1294,30 @@ "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/docker-compose.yaml": "3faf6dca7e3d9912ddee8af4c4b9fe9ce4fed6e80f0d0324a76794111eda8429", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/team/scenario/episode.yaml": "f0c27c9226568b5e287a11688a0cf979c04e95b5818bc9a52eb6938555b2135e", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/team/scenario/notes.md": "556d0f07dfbe93d218622c91e33ba4c6e72cb81ce392bf8aff3f992f320a21de", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/team/scenario/record.json": "32c6a5b4a8a5600890f2d6e8f2d1f81f2817a68e3e168c2e579adc835d23f49c", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/team/scenario/source.md": "ab9846f9d6618fffcb07920e88b8550d8a76a374b75afd45ccc11588c9c5d1f5", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/team/task.json": "90ac26b49ffeb6544995613602feef561af987dac1769e6021e9055d3adc6aa9", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/team/task.json": "983482e33330ffc8b429abbc879b93b07bdc59373d12aea494e669654ce659f7", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/task.toml": "48c121318dd77e407607f5c6e74c2c36c1641ca176c28538ca779db489be80aa", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/task.toml": "108b5dd9c1f746ac17cc4816d737b506af6287ddb4811296133a5e2883e29d6f", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/tests/expected.json": "7a735cfd0a544d1d96ba8a5b4c73658ff16023f51e7e4cffe666ed9a5946ba11", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/tests/scenario/episode.yaml": "f0c27c9226568b5e287a11688a0cf979c04e95b5818bc9a52eb6938555b2135e", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/tests/scenario/notes.md": "556d0f07dfbe93d218622c91e33ba4c6e72cb81ce392bf8aff3f992f320a21de", "tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/tests/scenario/record.json": "32c6a5b4a8a5600890f2d6e8f2d1f81f2817a68e3e168c2e579adc835d23f49c", @@ -1332,30 +1336,30 @@ "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/docker-compose.yaml": "53f392d192735d076d005ff5480f29ab96c9c86ac7619915873d52470ebdb471", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/team/scenario/episode.yaml": "23e4958898ba99be15e767b326e63a2ca4d37add5142e8eb7c34e71696e1b395", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/team/scenario/notes.md": "6dd94d195900505e371e58846e989a296b47119f70f9c4c9d05a4593bddc10ba", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/team/scenario/record.json": "e1202d735edc6ec5dfd9d9df57ff06fdd8449960e177794ffd5c8369bdb9e62f", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/team/scenario/source.md": "14a084715d61727ddacc573abbb5da74167cad65f922a5647622bbe9f46db18c", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/team/task.json": "f4eb6bca0c2766e92b10435f73f66c3bc3348a8bfeade5d56adebeca9d113a86", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/team/task.json": "c05d49073f7d9f387509505ee681c4a798f83a98f0395bcc335cd9364755b86c", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/task.toml": "d5a87e1700e0319638f390f10c00a674c4908e10fad06f4b54d833c3add17f70", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/task.toml": "7caa10245de31657881bb5dc9fe473f166cff82ee057c0e5d08a7b45d61e4871", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/tests/expected.json": "ddf0b7a2333024934999f012d2033fa41c4278b66950a47863bea70437db39d7", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/tests/scenario/episode.yaml": "23e4958898ba99be15e767b326e63a2ca4d37add5142e8eb7c34e71696e1b395", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/tests/scenario/notes.md": "6dd94d195900505e371e58846e989a296b47119f70f9c4c9d05a4593bddc10ba", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/tests/scenario/record.json": "e1202d735edc6ec5dfd9d9df57ff06fdd8449960e177794ffd5c8369bdb9e62f", @@ -1374,30 +1378,30 @@ "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/docker-compose.yaml": "955d7e41257566b72f81da8d2183adca7f27a89055b61ff6aeb07e63e076da95", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/team/scenario/episode.yaml": "23e4958898ba99be15e767b326e63a2ca4d37add5142e8eb7c34e71696e1b395", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/team/scenario/notes.md": "6dd94d195900505e371e58846e989a296b47119f70f9c4c9d05a4593bddc10ba", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/team/scenario/record.json": "e1202d735edc6ec5dfd9d9df57ff06fdd8449960e177794ffd5c8369bdb9e62f", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/team/scenario/source.md": "14a084715d61727ddacc573abbb5da74167cad65f922a5647622bbe9f46db18c", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/team/task.json": "24ab4670afa3f93460c918565eddccc4ca6778d07f9b0673256326ba05649d78", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/team/task.json": "d5134bb28df9efb73d7133972cc7da0fca6858feca36d4b19cc947588b4fd1a0", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/task.toml": "77cd81f8700e4808b499c42d998608e5083c8c914959e68daee35c4c019993e3", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/task.toml": "44e30a82d3cba5e3f9aa00976d2882574e3b55ce5e2b2e10f5fa17c7ad5a7d1b", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/tests/expected.json": "3831bf956e00da16fb008c26747c09271de236b8e918bbdf28e2288fc7296dbd", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/tests/scenario/episode.yaml": "23e4958898ba99be15e767b326e63a2ca4d37add5142e8eb7c34e71696e1b395", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/tests/scenario/notes.md": "6dd94d195900505e371e58846e989a296b47119f70f9c4c9d05a4593bddc10ba", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/tests/scenario/record.json": "e1202d735edc6ec5dfd9d9df57ff06fdd8449960e177794ffd5c8369bdb9e62f", @@ -1416,30 +1420,30 @@ "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/docker-compose.yaml": "71d256f8e84853f10672cb92d149fdda94e8a3b7b4b96099dd2bd8af0a7a2242", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/team/scenario/episode.yaml": "23e4958898ba99be15e767b326e63a2ca4d37add5142e8eb7c34e71696e1b395", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/team/scenario/notes.md": "6dd94d195900505e371e58846e989a296b47119f70f9c4c9d05a4593bddc10ba", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/team/scenario/record.json": "e1202d735edc6ec5dfd9d9df57ff06fdd8449960e177794ffd5c8369bdb9e62f", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/team/scenario/source.md": "14a084715d61727ddacc573abbb5da74167cad65f922a5647622bbe9f46db18c", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/team/task.json": "e07dbfe4b8134a606144ae6b3c774c2a7f6f5c32017099b00cbf1ebd57952eec", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/team/task.json": "cd752c6b789a23678ae646e9dadf31d5e572bafcfcd61a183fecd915d8e17d29", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/task.toml": "659d9d9971d4e6002f0adfde3bd2aefca6b69f00304a47943adb1f2c04779111", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/task.toml": "cced5ce71170211f7ad8dc730591cf5e023e1e2561a33ddad23452ddde5a1740", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/tests/expected.json": "8a62e862e170832481e14b12ce495251a31e2cc752273f26dfcd57ccb2c1dd84", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/tests/scenario/episode.yaml": "23e4958898ba99be15e767b326e63a2ca4d37add5142e8eb7c34e71696e1b395", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/tests/scenario/notes.md": "6dd94d195900505e371e58846e989a296b47119f70f9c4c9d05a4593bddc10ba", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/tests/scenario/record.json": "e1202d735edc6ec5dfd9d9df57ff06fdd8449960e177794ffd5c8369bdb9e62f", @@ -1458,30 +1462,30 @@ "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/docker-compose.yaml": "361af19b844d8de094ad5f245eefeaf72fceecb57bdcc2611e58e51108868143", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/team/scenario/episode.yaml": "23e4958898ba99be15e767b326e63a2ca4d37add5142e8eb7c34e71696e1b395", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/team/scenario/notes.md": "6dd94d195900505e371e58846e989a296b47119f70f9c4c9d05a4593bddc10ba", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/team/scenario/record.json": "e1202d735edc6ec5dfd9d9df57ff06fdd8449960e177794ffd5c8369bdb9e62f", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/team/scenario/source.md": "14a084715d61727ddacc573abbb5da74167cad65f922a5647622bbe9f46db18c", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/team/task.json": "c9100dc641c8a9778da1118a7a04aec7deb7d367b3466949b092e4510af1bb63", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/team/task.json": "456043aa026b6725fea8dff933078120bfd1dc407fef70ed3b764a94483ac3ef", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/task.toml": "7eb04667926b9e1ea6cb2d708d3f2f47183e8870ca6177d7bf823f527f3e99f1", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/task.toml": "deaffddf40cbd49f684a85a943430a7438c14ce2d83b9f5e201b84a5de479088", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/tests/expected.json": "39cde621b19602e018c2ce3a4917f2a5961291af605dfb764d840f9f196589b2", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/tests/scenario/episode.yaml": "23e4958898ba99be15e767b326e63a2ca4d37add5142e8eb7c34e71696e1b395", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/tests/scenario/notes.md": "6dd94d195900505e371e58846e989a296b47119f70f9c4c9d05a4593bddc10ba", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/tests/scenario/record.json": "e1202d735edc6ec5dfd9d9df57ff06fdd8449960e177794ffd5c8369bdb9e62f", @@ -1500,30 +1504,30 @@ "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/docker-compose.yaml": "9afe233f62a4c2381f40751715c64217b3d7fbb2e777170cf6bbf9ddcb6cc7ba", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/team/scenario/episode.yaml": "23e4958898ba99be15e767b326e63a2ca4d37add5142e8eb7c34e71696e1b395", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/team/scenario/notes.md": "6dd94d195900505e371e58846e989a296b47119f70f9c4c9d05a4593bddc10ba", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/team/scenario/record.json": "e1202d735edc6ec5dfd9d9df57ff06fdd8449960e177794ffd5c8369bdb9e62f", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/team/scenario/source.md": "14a084715d61727ddacc573abbb5da74167cad65f922a5647622bbe9f46db18c", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/team/task.json": "4ac4df4f0682d4a430ca35e92dcff26e59e76c4602b0a5d5d9d2e69b6872c637", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/team/task.json": "2ee164dff830bb29da4024653af7ba9614d37b6d38a1dfd45cf7d309ffdcb297", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/task.toml": "1aaba72d5b75a03ddfdc27ef75e5b02433e4a40283246b8d1b74884ffead5b04", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/task.toml": "daf513a894750db70317b5ad700b30629f284dfb4854afacf44bbb56d0f9051c", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/tests/expected.json": "2d7a96a27a280f1207daa96b3b8a11970b484284a8688779796ea77339ab7a4b", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/tests/scenario/episode.yaml": "23e4958898ba99be15e767b326e63a2ca4d37add5142e8eb7c34e71696e1b395", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/tests/scenario/notes.md": "6dd94d195900505e371e58846e989a296b47119f70f9c4c9d05a4593bddc10ba", "tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/tests/scenario/record.json": "e1202d735edc6ec5dfd9d9df57ff06fdd8449960e177794ffd5c8369bdb9e62f", @@ -1542,19 +1546,19 @@ "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/docker-compose.yaml": "e29d27b5a5b03e0a7afc53c2f91169f6257246f50477a87f42839abe51721eb1", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/team/scenario/episode.yaml": "369b9e0777ad6a13308d4a987952165370d3a81c37dc78a4ed03d134137732e2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/team/scenario/notes.md": "4aef9fc1190070904e70d43ca6f2e4f363ce42309dc987b722e68e52caf16e30", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/team/scenario/record.json": "f14829fdcf67c1a99a6b594ea6f1f21fe10f4b1c9ec049d4ecc2bea825740cc0", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/team/scenario/source.md": "983fbf7f1a0d0af91d52be143da829202d7a52bdffc5c2bd6744c592b5be352b", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/team/task.json": "200fb2ae3d653cb88b1eae1bc310477cf5f3e53c84f32a5c921cfecde75ff5ce", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/team/task.json": "9687fb5e883dd96503ad77646d5b5320c5790641130e14652c5dfd9fdb981481", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -1567,13 +1571,13 @@ "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/task.toml": "a730333c6104f9a90f607659d24b08a795b1ca9f6bcaefc10dcbf4e0b7daa169", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/task.toml": "5d1b4606d4d3cc0693ffa4d3284b6db9b2a38e2f2a8d4ae782a9eeffbd318d29", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/tests/expected.json": "4762f0eb7d57b6fc4c96336431489693bfc51e0e453fad9148199c0e9df0921f", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/tests/scenario/episode.yaml": "369b9e0777ad6a13308d4a987952165370d3a81c37dc78a4ed03d134137732e2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/tests/scenario/notes.md": "4aef9fc1190070904e70d43ca6f2e4f363ce42309dc987b722e68e52caf16e30", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/tests/scenario/record.json": "f14829fdcf67c1a99a6b594ea6f1f21fe10f4b1c9ec049d4ecc2bea825740cc0", @@ -1592,19 +1596,19 @@ "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/docker-compose.yaml": "2d0fd4292348bbce7c5a66fe3a0a2f2742ae3731c5b930e52e887c0b910cd157", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/team/scenario/episode.yaml": "369b9e0777ad6a13308d4a987952165370d3a81c37dc78a4ed03d134137732e2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/team/scenario/notes.md": "4aef9fc1190070904e70d43ca6f2e4f363ce42309dc987b722e68e52caf16e30", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/team/scenario/record.json": "f14829fdcf67c1a99a6b594ea6f1f21fe10f4b1c9ec049d4ecc2bea825740cc0", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/team/scenario/source.md": "983fbf7f1a0d0af91d52be143da829202d7a52bdffc5c2bd6744c592b5be352b", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/team/task.json": "4c22275a9902bf6b2c7b587ddeadaf66d4f261dc43c641a9fd565867bfffda58", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/team/task.json": "4f20f8e6d8346f9bb65ce800c6168c3fcae830d5b8616f4880ac7368b3043269", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -1617,13 +1621,13 @@ "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/task.toml": "3ea83cd6096184542e4fc87b6fe6b88af1de3ef68f19dcb335feddef920287b0", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/task.toml": "8a2734d5ad073471edb7a9d899b18c3a7bd07491bedf030996db127880f6ab65", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/tests/expected.json": "ffddcc6646d8234f80c9ea73b763b7501366dbfc1f1fa0555a81e8ee5adc7ce5", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/tests/scenario/episode.yaml": "369b9e0777ad6a13308d4a987952165370d3a81c37dc78a4ed03d134137732e2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/tests/scenario/notes.md": "4aef9fc1190070904e70d43ca6f2e4f363ce42309dc987b722e68e52caf16e30", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/tests/scenario/record.json": "f14829fdcf67c1a99a6b594ea6f1f21fe10f4b1c9ec049d4ecc2bea825740cc0", @@ -1642,19 +1646,19 @@ "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/docker-compose.yaml": "004875a02d0ba89a36df255057926d5f0d490a71292fa661094fe72baddc1113", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/team/scenario/episode.yaml": "369b9e0777ad6a13308d4a987952165370d3a81c37dc78a4ed03d134137732e2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/team/scenario/notes.md": "4aef9fc1190070904e70d43ca6f2e4f363ce42309dc987b722e68e52caf16e30", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/team/scenario/record.json": "f14829fdcf67c1a99a6b594ea6f1f21fe10f4b1c9ec049d4ecc2bea825740cc0", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/team/scenario/source.md": "983fbf7f1a0d0af91d52be143da829202d7a52bdffc5c2bd6744c592b5be352b", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/team/task.json": "3e35a3ccab56ff72b06f122c7828db6271d4c33b8c70529807425b213d0a93dd", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/team/task.json": "3477fccdc3f055a4081801742bd225960ebc1e0b111f3d8bb30a3beee038ce70", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -1667,13 +1671,13 @@ "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/task.toml": "4e83228b285516730a001b5703091be4661b33bd44f552cf0a647caef65542ee", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/task.toml": "b8f2d3aba38c5e224564ff9b2fa494298b789b4d8e11f3827166f4127eb59923", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/tests/expected.json": "afc2809501797f02f0dde847e20198f3417d25164afd74d0af6efc357422c588", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/tests/scenario/episode.yaml": "369b9e0777ad6a13308d4a987952165370d3a81c37dc78a4ed03d134137732e2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/tests/scenario/notes.md": "4aef9fc1190070904e70d43ca6f2e4f363ce42309dc987b722e68e52caf16e30", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/tests/scenario/record.json": "f14829fdcf67c1a99a6b594ea6f1f21fe10f4b1c9ec049d4ecc2bea825740cc0", @@ -1692,19 +1696,19 @@ "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/docker-compose.yaml": "20b22e6a33616ae2c9cad27890ecce8ea9932183163a4ef25b7d6e090461b728", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/team/scenario/episode.yaml": "369b9e0777ad6a13308d4a987952165370d3a81c37dc78a4ed03d134137732e2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/team/scenario/notes.md": "4aef9fc1190070904e70d43ca6f2e4f363ce42309dc987b722e68e52caf16e30", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/team/scenario/record.json": "f14829fdcf67c1a99a6b594ea6f1f21fe10f4b1c9ec049d4ecc2bea825740cc0", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/team/scenario/source.md": "983fbf7f1a0d0af91d52be143da829202d7a52bdffc5c2bd6744c592b5be352b", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/team/task.json": "daa7234d3a4be419e7823f2dc5e3b018fc0fb07517f5d44ba685da87f885f169", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/team/task.json": "1a1eb9385b80bda45da8fdf3dce0c9e6110414f57b37be1ec6fbf929481c3d7b", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -1717,13 +1721,13 @@ "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/task.toml": "afb1a6bcdbd9a8c3d5987274b3aee71f64c3d7e462c38609b65abb339de354fa", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/task.toml": "c0ce2d39d14aa72b317617a80482de3b1236c91ba6149bdc17cec572c40c466b", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/tests/expected.json": "a691c1b8ae59542be6246ce4973dbed58296404cc31eebe8d017758e5352290b", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/tests/scenario/episode.yaml": "369b9e0777ad6a13308d4a987952165370d3a81c37dc78a4ed03d134137732e2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/tests/scenario/notes.md": "4aef9fc1190070904e70d43ca6f2e4f363ce42309dc987b722e68e52caf16e30", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/tests/scenario/record.json": "f14829fdcf67c1a99a6b594ea6f1f21fe10f4b1c9ec049d4ecc2bea825740cc0", @@ -1742,19 +1746,19 @@ "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/docker-compose.yaml": "e7094380cd604fbb04b53bda1eddde1b3501bc97818b75066250e7e745b0c3a2", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/team/scenario/episode.yaml": "369b9e0777ad6a13308d4a987952165370d3a81c37dc78a4ed03d134137732e2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/team/scenario/notes.md": "4aef9fc1190070904e70d43ca6f2e4f363ce42309dc987b722e68e52caf16e30", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/team/scenario/record.json": "f14829fdcf67c1a99a6b594ea6f1f21fe10f4b1c9ec049d4ecc2bea825740cc0", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/team/scenario/source.md": "983fbf7f1a0d0af91d52be143da829202d7a52bdffc5c2bd6744c592b5be352b", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/team/task.json": "ef99ddec3ac4b75b1d80793ce5a525cdb2b2745931b87d46ffff417963e61d76", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/team/task.json": "2276bed2d3fc1bfbf65ed6dab5f5a0daa631476dbfb297027b2b89340d8c507b", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -1767,13 +1771,13 @@ "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/task.toml": "10da1d4af659ae0184edda408a9e9f2ebf2c6a811118fcfd67b850529915a161", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/task.toml": "36f8edc3a23e7404833972e14760a50af4c7c8b0b07801abeb9a0e935c32b08a", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/tests/expected.json": "f701585170661020d506e03e18cb9935abbeb61387615d6c4c589c0233098865", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/tests/scenario/episode.yaml": "369b9e0777ad6a13308d4a987952165370d3a81c37dc78a4ed03d134137732e2", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/tests/scenario/notes.md": "4aef9fc1190070904e70d43ca6f2e4f363ce42309dc987b722e68e52caf16e30", "tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/tests/scenario/record.json": "f14829fdcf67c1a99a6b594ea6f1f21fe10f4b1c9ec049d4ecc2bea825740cc0", @@ -1792,31 +1796,31 @@ "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/docker-compose.yaml": "773c86c0a981b8ce3395a9fe687b3a72b8f420464cf2414a7ed46f30286091e1", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/team/scenario/LICENSE": "474c4c8874b7a248c36d1983674003f78b52b98ddd1d939915053cbfa26dd227", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/team/scenario/episode.yaml": "eb8a28e6633aaaf9e368efdbcec6da81b6dbe94270e9b903df4b99678872f291", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/team/scenario/notes.md": "c98f9f6e3b8ea1bf5cdac6b4045b3bdf31074a76a30cbe9ddbe2b11129abe276", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/team/scenario/record.json": "007f1fd07fd0b48f94346cc11eea9b7284609ec5385d3f59fe027ac5255d1294", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/team/scenario/source.md": "f335cbe387510993b65fcb2c59d7469e3292741e7bf63a1ef6741b1e12395c63", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/team/task.json": "885e5b5cd95a501e4b62cb44532858cb2c654a23e27c3a3a372a8c1e6197ef5b", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/team/task.json": "6f82166a60cf37cf98fd6ad0c6d5fd1e034555ab217e6850b5cadb215d19431c", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/task.toml": "cc5740536d228bfbbd1cdf2a1a70e41f33ff10da5f808ccceaa5f217f19db258", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/task.toml": "483cf7050d54c3722afbb628b83078d7211c58c1bdcdd7fa3d58ff1ad4658f40", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/tests/expected.json": "83738aca0318c781e658e45ec7e2be6195f468adbf63292df48ed91cf8fdfe35", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/tests/scenario/LICENSE": "474c4c8874b7a248c36d1983674003f78b52b98ddd1d939915053cbfa26dd227", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/tests/scenario/episode.yaml": "eb8a28e6633aaaf9e368efdbcec6da81b6dbe94270e9b903df4b99678872f291", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/tests/scenario/notes.md": "c98f9f6e3b8ea1bf5cdac6b4045b3bdf31074a76a30cbe9ddbe2b11129abe276", @@ -1836,31 +1840,31 @@ "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/docker-compose.yaml": "ec31959572458996288031762433f881ffd4077aec53bcf430cc17ca1fd81d27", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/team/scenario/LICENSE": "474c4c8874b7a248c36d1983674003f78b52b98ddd1d939915053cbfa26dd227", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/team/scenario/episode.yaml": "eb8a28e6633aaaf9e368efdbcec6da81b6dbe94270e9b903df4b99678872f291", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/team/scenario/notes.md": "c98f9f6e3b8ea1bf5cdac6b4045b3bdf31074a76a30cbe9ddbe2b11129abe276", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/team/scenario/record.json": "007f1fd07fd0b48f94346cc11eea9b7284609ec5385d3f59fe027ac5255d1294", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/team/scenario/source.md": "f335cbe387510993b65fcb2c59d7469e3292741e7bf63a1ef6741b1e12395c63", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/team/task.json": "59128bae9f4f68f88b98a6d34e93ec0eb28db40e6ecf4f4e4388cf35937fd124", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/team/task.json": "85c3a58d1083718c1bf889e7060bd0e21b6a9265d9ff77aadfa094bfa9c2dd30", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/task.toml": "1c5b455d6573d6bc90b475274cc5edf3e6ab07518ac4122d4bbb8b9fad6a362a", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/task.toml": "923d6f050cd6c3a4b96494606a1cb78c02b50916849f30c91753effa5a890a97", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/tests/expected.json": "cfab7a97238a0356288c219009bb0b314f9a7a7b1a4fefe9112321a7cdb21bf7", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/tests/scenario/LICENSE": "474c4c8874b7a248c36d1983674003f78b52b98ddd1d939915053cbfa26dd227", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/tests/scenario/episode.yaml": "eb8a28e6633aaaf9e368efdbcec6da81b6dbe94270e9b903df4b99678872f291", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/tests/scenario/notes.md": "c98f9f6e3b8ea1bf5cdac6b4045b3bdf31074a76a30cbe9ddbe2b11129abe276", @@ -1880,31 +1884,31 @@ "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/docker-compose.yaml": "613ce533b4602772e5f5c0ce3bb919243466432ff02d259e41ce841bc7b46a5e", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/team/scenario/LICENSE": "474c4c8874b7a248c36d1983674003f78b52b98ddd1d939915053cbfa26dd227", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/team/scenario/episode.yaml": "eb8a28e6633aaaf9e368efdbcec6da81b6dbe94270e9b903df4b99678872f291", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/team/scenario/notes.md": "c98f9f6e3b8ea1bf5cdac6b4045b3bdf31074a76a30cbe9ddbe2b11129abe276", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/team/scenario/record.json": "007f1fd07fd0b48f94346cc11eea9b7284609ec5385d3f59fe027ac5255d1294", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/team/scenario/source.md": "f335cbe387510993b65fcb2c59d7469e3292741e7bf63a1ef6741b1e12395c63", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/team/task.json": "e200da541f35bed52eb23e4918453d2d99ed62d46c598dab7328d106e1b7b232", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/team/task.json": "5c9a5275600d6f28993e45181979df33d8c7a5ea16c67876ac1c251ecbfde227", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/task.toml": "1f3be8ecaadfcd0350ede90eee2cb6d42fb188a2ecfcd8643d1bbd8b6d4cdbdf", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/task.toml": "f93cea2ed557fdcbf3a33e0181ba070977b207d83fb5aad1634c8abeda6d9786", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/tests/expected.json": "da3e474494c76f3f827b81f0c9145e753992179888bc4c61312066c83ce6416e", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/tests/scenario/LICENSE": "474c4c8874b7a248c36d1983674003f78b52b98ddd1d939915053cbfa26dd227", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/tests/scenario/episode.yaml": "eb8a28e6633aaaf9e368efdbcec6da81b6dbe94270e9b903df4b99678872f291", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/tests/scenario/notes.md": "c98f9f6e3b8ea1bf5cdac6b4045b3bdf31074a76a30cbe9ddbe2b11129abe276", @@ -1924,31 +1928,31 @@ "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/docker-compose.yaml": "f49cee293e8a562b73aa27aea2bb027be2385ffdcbd150d3650c8111ff973cb2", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/team/scenario/LICENSE": "474c4c8874b7a248c36d1983674003f78b52b98ddd1d939915053cbfa26dd227", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/team/scenario/episode.yaml": "eb8a28e6633aaaf9e368efdbcec6da81b6dbe94270e9b903df4b99678872f291", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/team/scenario/notes.md": "c98f9f6e3b8ea1bf5cdac6b4045b3bdf31074a76a30cbe9ddbe2b11129abe276", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/team/scenario/record.json": "007f1fd07fd0b48f94346cc11eea9b7284609ec5385d3f59fe027ac5255d1294", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/team/scenario/source.md": "f335cbe387510993b65fcb2c59d7469e3292741e7bf63a1ef6741b1e12395c63", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/team/task.json": "0222e652df80589bf4aa3b56b1ad2c76ae14eebfa36e5ddcd7ddf036f25e2aec", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/team/task.json": "ad1f028aba1a4ed5c33b17f6fc544c2546619730b47c29cdf6e49cd836510fad", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/task.toml": "5ad885a49f45f712fc2967c4b00518564ef8b987aa9e0bde79fe930ef80e6d42", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/task.toml": "27a489d6d6c3c2a1906f00ecf3ee1760a83df96b32bc51f06620d31e1fd40211", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/tests/expected.json": "95d72c578d786bd3fb02c311f26b71795bfbd71229251ee12a8a5b70f6c7fc7b", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/tests/scenario/LICENSE": "474c4c8874b7a248c36d1983674003f78b52b98ddd1d939915053cbfa26dd227", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/tests/scenario/episode.yaml": "eb8a28e6633aaaf9e368efdbcec6da81b6dbe94270e9b903df4b99678872f291", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/tests/scenario/notes.md": "c98f9f6e3b8ea1bf5cdac6b4045b3bdf31074a76a30cbe9ddbe2b11129abe276", @@ -1968,31 +1972,31 @@ "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/docker-compose.yaml": "7560be600294adb5b770972af8459ecab4ca17980b67e4fbfc8232eafac5282b", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/team/scenario/LICENSE": "474c4c8874b7a248c36d1983674003f78b52b98ddd1d939915053cbfa26dd227", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/team/scenario/episode.yaml": "eb8a28e6633aaaf9e368efdbcec6da81b6dbe94270e9b903df4b99678872f291", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/team/scenario/notes.md": "c98f9f6e3b8ea1bf5cdac6b4045b3bdf31074a76a30cbe9ddbe2b11129abe276", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/team/scenario/record.json": "007f1fd07fd0b48f94346cc11eea9b7284609ec5385d3f59fe027ac5255d1294", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/team/scenario/source.md": "f335cbe387510993b65fcb2c59d7469e3292741e7bf63a1ef6741b1e12395c63", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/team/task.json": "121dff4163a8735691cd88a99d418c7278917ebaab39f979176c1e436a30487d", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/team/task.json": "a4881968bf9726887d7f381ec048c22bce634c33d13dd03f2abd39bd316b165d", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/task.toml": "4f3ce294cb01515b6abbb1a4bf6aa08fae63420efda64b48087f9bfe283c237b", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/task.toml": "8098b46f170c4cb3873943d23314a78f6500b7bfaee1df57e097ea93348fcadd", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/tests/expected.json": "d25181bbc0282e3408af799c8cfb917367e367bca1b2dacf66f3edf547381676", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/tests/scenario/LICENSE": "474c4c8874b7a248c36d1983674003f78b52b98ddd1d939915053cbfa26dd227", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/tests/scenario/episode.yaml": "eb8a28e6633aaaf9e368efdbcec6da81b6dbe94270e9b903df4b99678872f291", "tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/tests/scenario/notes.md": "c98f9f6e3b8ea1bf5cdac6b4045b3bdf31074a76a30cbe9ddbe2b11129abe276", @@ -2012,30 +2016,30 @@ "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/docker-compose.yaml": "bd4c7ae103861b187368e9f0b85bac311c3f5529a426406f7c0cd0ce51dd3166", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/team/scenario/episode.yaml": "a824512a8367f769ed0b48d4582b42671ac667d752a061c59c3a567f5351595e", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/team/scenario/notes.md": "cf6d14c621ad53e640a26e574e60a88c0398de6cc5d81fe443da33e2b90d7d4c", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/team/scenario/record.json": "6fc104873ba1e1d9a63da5353dabe23e1999263f0290ffd805cdaec253d1258d", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/team/scenario/source.md": "46e830f1d8770ed3b559f3d1dc64e45ce23a95f091098387257bc4f37117ec6c", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/team/task.json": "ff66bc23dc56a9825ed1546a7053081a73183bbf4e2c5e645f3d718d4092a158", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/team/task.json": "a09bd30ddd9f1e38ac7cd29aef34ca0b5a93aeeb0926efb4fc37a48d7ec46601", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/task.toml": "20b5049b1f91b55351a3260d770251b13d8ac0eb764f60fdd3a23f6f7c307d05", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/task.toml": "c3cf55d8a50bd9d9df59dffc3f5ea8480da0c17c0599310f589db7dfb721805a", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/tests/expected.json": "7066813a0a759f49181712cad83d296bdd7691c35a9725056df3b364d85d243b", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/tests/scenario/episode.yaml": "a824512a8367f769ed0b48d4582b42671ac667d752a061c59c3a567f5351595e", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/tests/scenario/notes.md": "cf6d14c621ad53e640a26e574e60a88c0398de6cc5d81fe443da33e2b90d7d4c", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/tests/scenario/record.json": "6fc104873ba1e1d9a63da5353dabe23e1999263f0290ffd805cdaec253d1258d", @@ -2054,30 +2058,30 @@ "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/docker-compose.yaml": "466efad0214e79c7aa8249683bf77b308dc805609034c4e261977a4e0273f544", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/team/scenario/episode.yaml": "a824512a8367f769ed0b48d4582b42671ac667d752a061c59c3a567f5351595e", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/team/scenario/notes.md": "cf6d14c621ad53e640a26e574e60a88c0398de6cc5d81fe443da33e2b90d7d4c", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/team/scenario/record.json": "6fc104873ba1e1d9a63da5353dabe23e1999263f0290ffd805cdaec253d1258d", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/team/scenario/source.md": "46e830f1d8770ed3b559f3d1dc64e45ce23a95f091098387257bc4f37117ec6c", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/team/task.json": "b17f43e01d6a163195ae25156a0b6d9f7a0b3a4b60ee2ce7f33bd5d061bba9be", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/team/task.json": "5540236661b993286529630677c2ff1250529aaa3bfc6f3c7ff2aa9cf813b7b2", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/task.toml": "26e77be18fe0d853b5266a4141840dbdba1565f8eb1b7bd437bb040f9bee1e60", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/task.toml": "34e01e3575789817d172884b8d08948de73f797a65c546cab80ade7161ec665c", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/tests/expected.json": "fdf3f37e990e3523f2d5104dd69cc2cdaf036dfab7d9f535f1703a6f56d25365", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/tests/scenario/episode.yaml": "a824512a8367f769ed0b48d4582b42671ac667d752a061c59c3a567f5351595e", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/tests/scenario/notes.md": "cf6d14c621ad53e640a26e574e60a88c0398de6cc5d81fe443da33e2b90d7d4c", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/tests/scenario/record.json": "6fc104873ba1e1d9a63da5353dabe23e1999263f0290ffd805cdaec253d1258d", @@ -2096,30 +2100,30 @@ "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/docker-compose.yaml": "d00782f907a8b08d28c564af7d0a6020b705cbfd8e59fea7c47d5646433fa82c", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/team/scenario/episode.yaml": "a824512a8367f769ed0b48d4582b42671ac667d752a061c59c3a567f5351595e", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/team/scenario/notes.md": "cf6d14c621ad53e640a26e574e60a88c0398de6cc5d81fe443da33e2b90d7d4c", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/team/scenario/record.json": "6fc104873ba1e1d9a63da5353dabe23e1999263f0290ffd805cdaec253d1258d", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/team/scenario/source.md": "46e830f1d8770ed3b559f3d1dc64e45ce23a95f091098387257bc4f37117ec6c", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/team/task.json": "bb3750a5cdc26c1b63bc185651d7f44de4081d2089770c38329ee697f9d8e97b", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/team/task.json": "37de5fd5757f57cb3ebc818474a3bdeca7917e9f125bc8102121c07f13a0fbd4", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/task.toml": "09347bc9e03d07aefc3c28dee1cacad74d9d08c6c1a93060f50ae0bf9b1733ef", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/task.toml": "e7981076908c2dd59489e4ca5937b0534c8840bf0d0f3c942e8d83729237fbb8", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/tests/expected.json": "79b48e937367d8b48852951554af35b4881ee127d81c8413a0d24a88e11790e0", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/tests/scenario/episode.yaml": "a824512a8367f769ed0b48d4582b42671ac667d752a061c59c3a567f5351595e", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/tests/scenario/notes.md": "cf6d14c621ad53e640a26e574e60a88c0398de6cc5d81fe443da33e2b90d7d4c", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/tests/scenario/record.json": "6fc104873ba1e1d9a63da5353dabe23e1999263f0290ffd805cdaec253d1258d", @@ -2138,30 +2142,30 @@ "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/docker-compose.yaml": "223446692459b58107a2a7e10c4a470072db7fd0665507297acce883a5febc85", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/team/scenario/episode.yaml": "a824512a8367f769ed0b48d4582b42671ac667d752a061c59c3a567f5351595e", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/team/scenario/notes.md": "cf6d14c621ad53e640a26e574e60a88c0398de6cc5d81fe443da33e2b90d7d4c", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/team/scenario/record.json": "6fc104873ba1e1d9a63da5353dabe23e1999263f0290ffd805cdaec253d1258d", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/team/scenario/source.md": "46e830f1d8770ed3b559f3d1dc64e45ce23a95f091098387257bc4f37117ec6c", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/team/task.json": "afa6d4287137c334e7bf43a0ee1d3525a27c32b031d461595b2d5e3cd60a4017", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/team/task.json": "adae6f33ebbb39242eef97778dddf51b465c36d9efa83833c0e43e8f4acd3fe6", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/task.toml": "515bbb75c2cdfbd657043159f361863848496ef3088e0095d8ad999cd4ff8c1e", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/task.toml": "a7cacbb044896ad4385c6d39abe78bb0b65b3fe6adf2c9d1078088891e599247", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/tests/expected.json": "00e7db9dbf7d849bebfcfaa25453fa2a0488b789ec813904bf5c918439d2ef38", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/tests/scenario/episode.yaml": "a824512a8367f769ed0b48d4582b42671ac667d752a061c59c3a567f5351595e", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/tests/scenario/notes.md": "cf6d14c621ad53e640a26e574e60a88c0398de6cc5d81fe443da33e2b90d7d4c", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/tests/scenario/record.json": "6fc104873ba1e1d9a63da5353dabe23e1999263f0290ffd805cdaec253d1258d", @@ -2180,30 +2184,30 @@ "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/docker-compose.yaml": "e3fad4c0587302efce5c453b68f66fd87f78aca9d3199045c82a15da9cac0bae", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/team/scenario/episode.yaml": "a824512a8367f769ed0b48d4582b42671ac667d752a061c59c3a567f5351595e", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/team/scenario/notes.md": "cf6d14c621ad53e640a26e574e60a88c0398de6cc5d81fe443da33e2b90d7d4c", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/team/scenario/record.json": "6fc104873ba1e1d9a63da5353dabe23e1999263f0290ffd805cdaec253d1258d", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/team/scenario/source.md": "46e830f1d8770ed3b559f3d1dc64e45ce23a95f091098387257bc4f37117ec6c", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/team/task.json": "db072c98549f5052e438d753e1b7aa4bf29fb117b4ce03fd462695f8773f7050", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/team/task.json": "3486ab59251f9c1326a9464ee63bbe7ed27a57a27e200c68ecfaad4e0d0c37af", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/task.toml": "c1a867bb3a24bb57f269e1c497c314f63477ccc0fe83b36f5ac727c27037c787", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/task.toml": "aeca977af9c3b154819548de44c987f7d5815bec92fe33e5ed265032feeccecd", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/tests/expected.json": "40cfceb1c26f6de7bcdd6243b36dda03ce9eb704ffe88e8e5dec179066b3dcb6", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/tests/scenario/episode.yaml": "a824512a8367f769ed0b48d4582b42671ac667d752a061c59c3a567f5351595e", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/tests/scenario/notes.md": "cf6d14c621ad53e640a26e574e60a88c0398de6cc5d81fe443da33e2b90d7d4c", "tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/tests/scenario/record.json": "6fc104873ba1e1d9a63da5353dabe23e1999263f0290ffd805cdaec253d1258d", @@ -2222,19 +2226,19 @@ "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/docker-compose.yaml": "efc3fbfc1d90539d9c46f65b4ec98cb7286b42df63f65a7dfaf10e90b68969fe", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/team/scenario/episode.yaml": "4236c9b9cd0c914b1f9ac02c8dd8a2638ef8c9c72a274470b5fd02d945bda753", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/team/scenario/notes.md": "eab9d90580391e3bb9228d123adc4096e1ba5e2818cf893863e94df6fefb2cf2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/team/scenario/record.json": "c81466336324b94eae583aa901b1b73c534fd612dd0c4d18fab3190d78efcc29", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/team/scenario/source.md": "f90cfc50885ffe0dbafaca57b51443fc8ef88ce6a4f0a5f6beeda2f9fd5fcd56", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/team/task.json": "434136c23a961c72e5840890586b2dc00b0eeddd1b8837dafcb5efc5adf46e9a", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/team/task.json": "4241caf50521854b50293b775ab974045e59e29562ab989d458bb91d5bf39b3f", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -2247,13 +2251,13 @@ "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/task.toml": "f2088353abcc986ed9052d0e68450eebf7027e6d31131c4e1475640bed5033ec", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/task.toml": "aee2e13e2f3eebce8717133c8a447de72283119481c798b256bf7baf473632f3", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/tests/expected.json": "f422756bb52817a0b54d8c8925d6823029e05a6d53c4b3b85b43da8481921a76", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/tests/scenario/episode.yaml": "4236c9b9cd0c914b1f9ac02c8dd8a2638ef8c9c72a274470b5fd02d945bda753", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/tests/scenario/notes.md": "eab9d90580391e3bb9228d123adc4096e1ba5e2818cf893863e94df6fefb2cf2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/tests/scenario/record.json": "c81466336324b94eae583aa901b1b73c534fd612dd0c4d18fab3190d78efcc29", @@ -2272,19 +2276,19 @@ "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/docker-compose.yaml": "65545b798c33507a5e74f3a8c21e92a3068232d74a76ab2d786b96aa8837345d", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/team/scenario/episode.yaml": "4236c9b9cd0c914b1f9ac02c8dd8a2638ef8c9c72a274470b5fd02d945bda753", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/team/scenario/notes.md": "eab9d90580391e3bb9228d123adc4096e1ba5e2818cf893863e94df6fefb2cf2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/team/scenario/record.json": "c81466336324b94eae583aa901b1b73c534fd612dd0c4d18fab3190d78efcc29", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/team/scenario/source.md": "f90cfc50885ffe0dbafaca57b51443fc8ef88ce6a4f0a5f6beeda2f9fd5fcd56", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/team/task.json": "1898ee37d92c03d097cdf076f3f930421eae008852ed8dd0a8ccab089f031f75", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/team/task.json": "6fe1d33ce3b1a0ab3ab0cbcdf47ea9a8d68b23206954174d3a42ce230384bb49", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -2297,13 +2301,13 @@ "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/task.toml": "9b5aa5427d0a917c79f75f15b1349ca8128020110cb6d4b9d3112d24ee2efff2", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/task.toml": "fd52fe8551e017e85f739b3055573e118f4bfffda15bc9d677d1fd548c192d32", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/tests/expected.json": "2d257cd14b55be103217000a2b248af0493402780717903b3bb2293a518490c9", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/tests/scenario/episode.yaml": "4236c9b9cd0c914b1f9ac02c8dd8a2638ef8c9c72a274470b5fd02d945bda753", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/tests/scenario/notes.md": "eab9d90580391e3bb9228d123adc4096e1ba5e2818cf893863e94df6fefb2cf2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/tests/scenario/record.json": "c81466336324b94eae583aa901b1b73c534fd612dd0c4d18fab3190d78efcc29", @@ -2322,19 +2326,19 @@ "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/docker-compose.yaml": "50df1fd5218e9932ec80ed12ce0832eab72d2fd5915cf8e5b14c031c7d450085", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/team/scenario/episode.yaml": "4236c9b9cd0c914b1f9ac02c8dd8a2638ef8c9c72a274470b5fd02d945bda753", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/team/scenario/notes.md": "eab9d90580391e3bb9228d123adc4096e1ba5e2818cf893863e94df6fefb2cf2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/team/scenario/record.json": "c81466336324b94eae583aa901b1b73c534fd612dd0c4d18fab3190d78efcc29", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/team/scenario/source.md": "f90cfc50885ffe0dbafaca57b51443fc8ef88ce6a4f0a5f6beeda2f9fd5fcd56", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/team/task.json": "5c30ab2383178659e6f6178f0497619512137eb22be890af4290973c08f9e8ca", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/team/task.json": "2aebe97b20064b7c36ce5d40436bf302a7fc324b9edcf6e2e71bb7bbb3d4f679", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -2347,13 +2351,13 @@ "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/task.toml": "bc8efcd640ff0ba03d2f4707756b620c280622757bdbb2762614f42dcc074776", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/task.toml": "128fd72a4e26e3e7e3f2cdc29f244595e796f3e8c40ea65ff3654bdf2154d8e4", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/tests/expected.json": "130fa780cf811fe4539e23ccf40a38ed3cc38e0ccd5270b4d23a5b1083136b37", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/tests/scenario/episode.yaml": "4236c9b9cd0c914b1f9ac02c8dd8a2638ef8c9c72a274470b5fd02d945bda753", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/tests/scenario/notes.md": "eab9d90580391e3bb9228d123adc4096e1ba5e2818cf893863e94df6fefb2cf2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/tests/scenario/record.json": "c81466336324b94eae583aa901b1b73c534fd612dd0c4d18fab3190d78efcc29", @@ -2372,19 +2376,19 @@ "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/docker-compose.yaml": "807f12bf7a6c7c91cfbcb08e5325f7cadfcf6067e46bc5a959016ac6596eeb6c", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/team/scenario/episode.yaml": "4236c9b9cd0c914b1f9ac02c8dd8a2638ef8c9c72a274470b5fd02d945bda753", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/team/scenario/notes.md": "eab9d90580391e3bb9228d123adc4096e1ba5e2818cf893863e94df6fefb2cf2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/team/scenario/record.json": "c81466336324b94eae583aa901b1b73c534fd612dd0c4d18fab3190d78efcc29", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/team/scenario/source.md": "f90cfc50885ffe0dbafaca57b51443fc8ef88ce6a4f0a5f6beeda2f9fd5fcd56", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/team/task.json": "9a3991c4b77cf99fd245ab7e7574fdeb143880971653b5424338c966fd12afd3", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/team/task.json": "44a30ae3000b510df81668ecd298264dd9cee4117bc9f9381554b4482ea64f1f", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -2397,13 +2401,13 @@ "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/task.toml": "9275e84746320f6387aa9c03ff3ddb2ca03ad965a63e4e9dcb7f16a0e75e4985", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/task.toml": "cf51df1d2546a779ba276c5474fecd422d03086fa70395c1373860d083f1af77", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/tests/expected.json": "ca0eee59dc87cce4b2615db89e5fbb9ade8774df0899beba65267bf92d35908c", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/tests/scenario/episode.yaml": "4236c9b9cd0c914b1f9ac02c8dd8a2638ef8c9c72a274470b5fd02d945bda753", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/tests/scenario/notes.md": "eab9d90580391e3bb9228d123adc4096e1ba5e2818cf893863e94df6fefb2cf2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/tests/scenario/record.json": "c81466336324b94eae583aa901b1b73c534fd612dd0c4d18fab3190d78efcc29", @@ -2422,19 +2426,19 @@ "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/docker-compose.yaml": "cc035e433c0d76aff51925e37edfd66cbecece464915e611379fb5ecc5f9a021", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/team/scenario/episode.yaml": "4236c9b9cd0c914b1f9ac02c8dd8a2638ef8c9c72a274470b5fd02d945bda753", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/team/scenario/notes.md": "eab9d90580391e3bb9228d123adc4096e1ba5e2818cf893863e94df6fefb2cf2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/team/scenario/record.json": "c81466336324b94eae583aa901b1b73c534fd612dd0c4d18fab3190d78efcc29", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/team/scenario/source.md": "f90cfc50885ffe0dbafaca57b51443fc8ef88ce6a4f0a5f6beeda2f9fd5fcd56", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/team/task.json": "cfa4ad0c27932dc4dbed7e0f617d8cfd248d395b4334bef05d1d29fe6aae7120", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/team/task.json": "3a67000d7344dce6e0e5a908ae4e505549899a08498401997f190194b707d4d2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -2447,13 +2451,13 @@ "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/task.toml": "e57eab4d9aeb67c457283a7bbfe5265615d428f1a5a2cafe1729f00d028db1c1", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/task.toml": "95421a580735a0f71a2a95bd0a45da0ab4fc0cceafbae66bdf01f5e355268eae", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/tests/expected.json": "f5570dbd98fcbe7be36f9f31cfdd394226542da20a36256b49242373f74f1374", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/tests/scenario/episode.yaml": "4236c9b9cd0c914b1f9ac02c8dd8a2638ef8c9c72a274470b5fd02d945bda753", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/tests/scenario/notes.md": "eab9d90580391e3bb9228d123adc4096e1ba5e2818cf893863e94df6fefb2cf2", "tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/tests/scenario/record.json": "c81466336324b94eae583aa901b1b73c534fd612dd0c4d18fab3190d78efcc29", @@ -2472,27 +2476,27 @@ "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/docker-compose.yaml": "e65e33edcbd910893bb8b18febc3df41ff44c6b63a18e9676c99ad447f6b4155", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/team/Dockerfile": "16d7f82e6bdb29ce8950d110c90f40a2c487156965809731f6bdca8670618d42", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/team/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/team/task.json": "908d1c5a21a4cb29ec18e1236e187cae8d7d399b4de5d6fb4857722b281d7086", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/team/task.json": "60e54e23331d08f70908fa3d19bc7723041c53db804cc428109e8b648bc452eb", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/task.toml": "808fd9bfff8751dd60c53f928513ae862d6d5a0e98eadaa96a00d41f0d86805b", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/task.toml": "7f860b0571f98d537b86739e91336e3587eb01d1f54bc896c32354c16d847445", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/tests/expected.json": "d5df2e5609e7932193de0b2822cb32cefc582e534fdb9d2a2c29401e2eba56ed", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/tests/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/tests/test.sh": "e28f4d75f6c2b40a5ae92103b2341d8c71541d500c91d1e6a2e7207639e37044", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -2508,27 +2512,27 @@ "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/docker-compose.yaml": "8df91d16fc48ddd757fc6a13164183b2d8df82df02b3025ada6d2015895bb7e4", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/team/Dockerfile": "16d7f82e6bdb29ce8950d110c90f40a2c487156965809731f6bdca8670618d42", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/team/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/team/task.json": "86fe9998618be7fef1acad23b2276e10c4355b8526cc19c71defa6d0fa41ba67", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/team/task.json": "b7d96043d1bcba8a98e88149a56fac290f7e70ead8aa33360b1cab8ebb886d16", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/task.toml": "1456cc62bda91505e7f77465a9aadd28d0b2f0ee8f6546653a1c02899df20c6d", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/task.toml": "47342c38bf54e1ff023ca2517596c5e15de0f0eb6c0e51e4bd929872583a0846", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/tests/expected.json": "51b78dc039048106d016301c344197b1b4da7ba8a308c460ca034909ccb84e33", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/tests/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/tests/test.sh": "e28f4d75f6c2b40a5ae92103b2341d8c71541d500c91d1e6a2e7207639e37044", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -2544,27 +2548,27 @@ "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/docker-compose.yaml": "e80f624f5aea3adcde78eb437d74e606ff236ba2401fc6d3f647c78ca5d2fa1f", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/team/Dockerfile": "16d7f82e6bdb29ce8950d110c90f40a2c487156965809731f6bdca8670618d42", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/team/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/team/task.json": "3dd9f0f5bac04d6f09205cacbb22198473eb2781df368fe5855cf4976df3d5ac", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/team/task.json": "58b3348f8a9c90d85507db714dbb69dbf52cc96a58a883dd0c92b3b8989d2e96", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/task.toml": "1d7cfd0024dbad367f2ef0c31d85e22d19d32cee0d70c3ca70d5c0db4b2fa03d", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/task.toml": "ab5a1aef587c3b3dec656c3020991f6bfec9fdbe43cb1a0d80f71ea95902c327", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/tests/expected.json": "780c465b27dbda065e8a68a0489c4ad302b0d01d038f3d371ad503c5c4db83aa", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/tests/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/tests/test.sh": "e28f4d75f6c2b40a5ae92103b2341d8c71541d500c91d1e6a2e7207639e37044", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -2580,27 +2584,27 @@ "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/docker-compose.yaml": "587115fff9d000d656620ca3264fbaa833b813b13303047f6a9b7605a598f511", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/team/Dockerfile": "16d7f82e6bdb29ce8950d110c90f40a2c487156965809731f6bdca8670618d42", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/team/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/team/task.json": "225889f4380b3c9ef81e903e51a16352e2f9524bc9ad4b83b8a80f7393f48ee1", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/team/task.json": "450b21cc5d7a5ef49bf6d87ec54280ac7ac98c7e93afb3e44614a771597b5d7e", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/task.toml": "cec30eb2cbe883bebd4c93e13662d9b553ff832c2ffa1a43e3885b01a9900a3f", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/task.toml": "161410556ddb029a45c208bc0686439882999bac219808e3da366b69c2c9f55a", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/tests/expected.json": "eef674ac3f20e8f02e60766d8a2e40d5ce6254e092ee926a81c968b81a869ab0", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/tests/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/tests/test.sh": "e28f4d75f6c2b40a5ae92103b2341d8c71541d500c91d1e6a2e7207639e37044", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -2616,27 +2620,27 @@ "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/docker-compose.yaml": "972caedb2fbc9d8ef730e5c624930fe92ffe77efdbafd7721d8ac0701599a558", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/team/Dockerfile": "16d7f82e6bdb29ce8950d110c90f40a2c487156965809731f6bdca8670618d42", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/team/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/team/task.json": "600294e31d363458d6c259de50df3442eef1500f19c58600b638728dee4e54b9", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/team/task.json": "03fc2d90d9288494706ffb2d0ba4205970b26612e6aeebff5fb23bdbdc1936ab", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/task.toml": "c5a52b924918e73a0bb87744b946fd813696e85434d9a29ed6020a3203725832", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/task.toml": "923617299c732348759e81782106475357432d872aaef1d2c2c7c68b07cc0ba5", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/tests/expected.json": "bec84f0b834429e99ae043b43244bb4b9db4aa3b7aa352e120c20d40a9ae5ae0", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/tests/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", "tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/tests/test.sh": "e28f4d75f6c2b40a5ae92103b2341d8c71541d500c91d1e6a2e7207639e37044", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -2652,27 +2656,27 @@ "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/docker-compose.yaml": "bd2e3c3adb5163483cfa5636bfe70864a490caf1f7802f61416c1c01ff4ccf26", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/team/Dockerfile": "16d7f82e6bdb29ce8950d110c90f40a2c487156965809731f6bdca8670618d42", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/team/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/team/task.json": "e2b89c90bfc23be2d42b8a258a7ecc7cf90dcf4aae12a7c63b4138e95558251b", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/team/task.json": "47366494c257dc428071adee8b85161f79d1d53d941b7f6d8c83e84ee91c92ad", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/task.toml": "4bbf541bd8b74729b2103f7156cac8fe3bf5b0fd0f08b4e29a3eeb77a499741a", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/task.toml": "e424fa8199ff56f089508b395c259a31294f7e9eac3a0f27665205e5288d66f1", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/tests/expected.json": "1fd7eb42c4fdad9ee89b43530d6292547f23b1bd6d3bcff53e01ec4a40a323c6", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/tests/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/tests/test.sh": "e28f4d75f6c2b40a5ae92103b2341d8c71541d500c91d1e6a2e7207639e37044", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -2688,27 +2692,27 @@ "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/docker-compose.yaml": "935b6bb01e985cc98558db9fb7073ede9b69703370d3af77eb0623d29a071216", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/team/Dockerfile": "16d7f82e6bdb29ce8950d110c90f40a2c487156965809731f6bdca8670618d42", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/team/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/team/task.json": "1a0ce3a5e43d324175ece7899604911bc4e21253348bfa47b902ea7298e55951", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/team/task.json": "00e2012ac0bbfb85f9044a690dcc4d808a826df2fb69beea08d94b9684bc3790", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/task.toml": "f060751579da20557fce2874029cb16dbd1ac05a55cc256abdf63cb80a486e3d", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/task.toml": "cb7b25c4f2fcf8553d2b4f434423f3b41ab66990d77a833f9c2d927bcec3a452", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/tests/expected.json": "d57b74fa04023b59799d7f0d1ea0482f5e2f128191a3de3ed66e863a27470899", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/tests/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/tests/test.sh": "e28f4d75f6c2b40a5ae92103b2341d8c71541d500c91d1e6a2e7207639e37044", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -2724,27 +2728,27 @@ "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/docker-compose.yaml": "57fa1b1dccb7e0d34337441fc3bc18c70d1d46016f47dc1968b07f6c16d03c39", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/team/Dockerfile": "16d7f82e6bdb29ce8950d110c90f40a2c487156965809731f6bdca8670618d42", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/team/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/team/task.json": "6ebb7b2dcb8450ec7bd76160d7608001bbf01beacb3fce6e883a834a5206b142", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/team/task.json": "666a9c668db7ad9197bbd84e829f8102e9e879e052d234819c050d2b98bcb0d3", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/task.toml": "98f66724ce2eee223e25c73387b1d8257a47a82e686e74feeb8256a270767eb1", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/task.toml": "485b46c6be32674389a458a27afe6851dc45a4c28840ef0a1836c957d54d3772", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/tests/expected.json": "eb7f6d657106dca1c05f7854d3431a983ad03450374ccd1d07c59964007fde02", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/tests/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/tests/test.sh": "e28f4d75f6c2b40a5ae92103b2341d8c71541d500c91d1e6a2e7207639e37044", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -2760,27 +2764,27 @@ "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/docker-compose.yaml": "b3066e98b642f0f51e3d9d16fa16c143e9db16b0153351118113267b47bb878e", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/team/Dockerfile": "16d7f82e6bdb29ce8950d110c90f40a2c487156965809731f6bdca8670618d42", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/team/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/team/task.json": "db4cf0117c46e57e0d47bde3ada3faad8895c0b0d1fd8dad108f3738313cec7b", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/team/task.json": "f23f9ae27107389415b18fae9a80a2576c8dcc7e9c117825da97528839751956", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/task.toml": "ce071f343b61e2a31b68a4097d30e13d2f5afe36738e7aab37e59d31dd6120c1", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/task.toml": "690c429d653d8c1150bf75b83580a0e103fa58cc0a98057d188c3aefb8f5fa37", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/tests/expected.json": "093f091905bf6a166d52f88e732f7cd89a6a7bb0a1ad499776646bd7a1324373", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/tests/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/tests/test.sh": "e28f4d75f6c2b40a5ae92103b2341d8c71541d500c91d1e6a2e7207639e37044", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -2796,27 +2800,27 @@ "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/docker-compose.yaml": "ca0e59eccb7d2a981f445576ec0a262b3e3a5c6fc7e9cf3ee9dcc89f5f548f9f", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/team/Dockerfile": "16d7f82e6bdb29ce8950d110c90f40a2c487156965809731f6bdca8670618d42", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/team/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/team/task.json": "d181de71b9a69eaccbe9cf3cd153401a6b3c2c58eb4f08edde89deeffa9ef32d", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/team/task.json": "ae8d798ff58287bc8c31d3ddacb6228df00af255712ce267d2ea9335ed9c6139", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/task.toml": "cee182a7bd14f2739766e449ab9f27705365ab3e5658a9e8872b6d3adec23026", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/task.toml": "7c2e8d38dd449498c7485e4a66946e2a64e7a2e807cd56cad6a59c51eb04d0fd", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/tests/expected.json": "1cec678cb1912033ea7daa6ed3c7ca9a9310468079a2f4795f8a3ce46ec2aded", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/tests/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", "tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/tests/test.sh": "e28f4d75f6c2b40a5ae92103b2341d8c71541d500c91d1e6a2e7207639e37044", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -2832,27 +2836,27 @@ "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/docker-compose.yaml": "cc940825ef59878b0c172d405b582ebc02482b53a1237a54a6200e2b713e09bd", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/team/Dockerfile": "16d7f82e6bdb29ce8950d110c90f40a2c487156965809731f6bdca8670618d42", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/team/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/team/task.json": "51f4dcc0e24d05a849b3afe6d89a9195131a9c3263be117f069df6bce0e92988", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/team/task.json": "0f63d5edec631a46781bdad6832161568cb2be148ae1a8ab0eed223ffb2f7504", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/task.toml": "38ee4420e9b1bfa642eba7bc953938f9b79259ad6ed13d3e620fa005297cd8af", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/task.toml": "d91a6c88d7b67c0a82cd2eafbec763be26a9def8f5168674602f9d90f297aa67", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/tests/expected.json": "ac9ba771f58a1d56a62c362659f2d2d89484950b1dcd4a715a09ce5701a808db", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/tests/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/tests/test.sh": "e28f4d75f6c2b40a5ae92103b2341d8c71541d500c91d1e6a2e7207639e37044", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -2868,27 +2872,27 @@ "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/docker-compose.yaml": "0e43563623d501ac3ac0273c6eea0aa6e2ea480342c23468b1053a1f2b05c87f", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/team/Dockerfile": "16d7f82e6bdb29ce8950d110c90f40a2c487156965809731f6bdca8670618d42", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/team/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/team/task.json": "c555eec58f1082f007046bc0ad7e1bbb160fcc4822e179fad8d58ef7510adb98", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/team/task.json": "7b6dc6a768e1aa9a878ba768c4c3b91990b0fbd753187885aff5405e90fa86d7", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/task.toml": "f1f7bf67a40665aed94d40dd7e46932cf840fa2449bc0e0e26c9150cf5e31977", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/task.toml": "bf639996d6e0da825bfaa5c329c14a86be04f599bfa5270fe5521db9de84f261", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/tests/expected.json": "07bc1d38e5f7afc85a1eea1d9c903680308d735cf33bfcfed3532c6fa0f5eb8b", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/tests/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/tests/test.sh": "e28f4d75f6c2b40a5ae92103b2341d8c71541d500c91d1e6a2e7207639e37044", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -2904,27 +2908,27 @@ "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/docker-compose.yaml": "3f463a17df3ac5ee093c288bb0becefc756dcbe31a7c29cea6916fb0a798205b", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/team/Dockerfile": "16d7f82e6bdb29ce8950d110c90f40a2c487156965809731f6bdca8670618d42", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/team/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/team/task.json": "1d8f440d95ce5dfb0e7803380ca3479f1a00671a4f45ba67006b03fc1870fadb", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/team/task.json": "36cca773821af52f5be145d282bb223db258c17b47486895277b8dfd44709371", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/task.toml": "f9e971ebab7e0ccec5126d067b6c8280a047f6385806516537d498da78fee38e", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/task.toml": "55c16a92d7fd8d633f289dee76cc6dd6f8a6d94572b77204b156c265b4e5b890", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/tests/expected.json": "bb786030c7203231ad9cb0724adb0a11f8d81f29fd42c2be7c866322c7d244b5", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/tests/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/tests/test.sh": "e28f4d75f6c2b40a5ae92103b2341d8c71541d500c91d1e6a2e7207639e37044", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -2940,27 +2944,27 @@ "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/docker-compose.yaml": "e1fdda34fdf5cfa99104e5157b2d71b675316a26d22fbf2ccb478150b5ddd450", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/team/Dockerfile": "16d7f82e6bdb29ce8950d110c90f40a2c487156965809731f6bdca8670618d42", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/team/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/team/task.json": "13a358e06dcc019a5171d5a1fb0ce85d01d99cc166fd1c9b6ed4a159d5c06252", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/team/task.json": "4c6b0df0287dc425369784b8c5635cee5366614414b1d45576910469dd339f23", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/task.toml": "774455acf76f944589f69c0a6202a0398c3ccbf849abbe5bef9e83cef0883e25", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/task.toml": "205f01e5628e30091a4b6195bc08ed14cda5fba098c56588c49d256daa27a104", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/tests/expected.json": "3b69eed9fa0d8c2c2b21fdcba9974e3acb5cdcfba3ddcb5f883b6d61e5c968e1", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/tests/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/tests/test.sh": "e28f4d75f6c2b40a5ae92103b2341d8c71541d500c91d1e6a2e7207639e37044", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -2976,27 +2980,27 @@ "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/docker-compose.yaml": "0472c82238c0639e1dbec4685a2d83e447aaf9d1a7c968c6dae5a569bc7a4132", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/team/Dockerfile": "16d7f82e6bdb29ce8950d110c90f40a2c487156965809731f6bdca8670618d42", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/team/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/team/task.json": "cfb5bf88883929c458855ab98d2b052acd5aa00096a93c8e16585697972d8156", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/team/task.json": "294bc94bd065bfa88fea248471e4115bff2225a891ac6236eb75dfc789e033fc", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/task.toml": "64a146d47ac1e34a98d9f8d1ffd898ee1e615441dda90cd742d6aa3821a61721", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/task.toml": "653f524e6f6c7da299efffbc57706958ac3688ac955c93b1d81cc87fc3298a5f", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/tests/expected.json": "d47fe560e9fff9c640f118c24b5d1db52b53a601e4c461e3068e08e26d8233d0", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/tests/scenario.zip": "52165b7f690d2a0098e08009a709916c49cd97da775f5bfaddb30267c7d6cdbb", "tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/tests/test.sh": "e28f4d75f6c2b40a5ae92103b2341d8c71541d500c91d1e6a2e7207639e37044", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -3012,30 +3016,30 @@ "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/docker-compose.yaml": "bbb3e5842946825cf106c85127a5bb7a07b79beb5a0695345df082262a27ab01", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/team/scenario/episode.yaml": "9608a536b76295582e0bb0d0c50fece4a3cc09e6d219562e95fe3844d4f032fd", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/team/scenario/notes.md": "3729b3d2746871f01ee09a8dac232524858d095480c2b20c10a03257c7feee0d", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/team/scenario/record.json": "b8ae088928e27c85b2046c51f7cd61f28843549dd2d83e35c74d72d2769026f5", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/team/scenario/source.md": "d21ef55d6d265f847f2ddbde0233f7552500f9b863b3620c3ebd55ea2e1e7517", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/team/task.json": "a2adffc3b1ff9dee622660e56cf000db239070ccf6797cb4860f442774d90d62", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/team/task.json": "696d86489a7a7fc382e51e4ba729a59475658adfc6c60a1c1c6a7d034133aac8", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/task.toml": "f44f3ce171df2399d232f9998615ee0a602658280746af1de7c1e13608aa3eed", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/task.toml": "0a7511d98e02344f06a254348a61b03a77f386e32ebd7cc712a75be0aed7d2b5", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/tests/expected.json": "abe6976edf172b030868087a8527bee6b8c9f8ea772d136c757a17c0c7e9ba13", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/tests/scenario/episode.yaml": "9608a536b76295582e0bb0d0c50fece4a3cc09e6d219562e95fe3844d4f032fd", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/tests/scenario/notes.md": "3729b3d2746871f01ee09a8dac232524858d095480c2b20c10a03257c7feee0d", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/tests/scenario/record.json": "b8ae088928e27c85b2046c51f7cd61f28843549dd2d83e35c74d72d2769026f5", @@ -3054,30 +3058,30 @@ "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/docker-compose.yaml": "3ae54b22afc0dfa10b798bc0d4610644706bea8626d3a59c315272d5b134365a", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/team/scenario/episode.yaml": "9608a536b76295582e0bb0d0c50fece4a3cc09e6d219562e95fe3844d4f032fd", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/team/scenario/notes.md": "3729b3d2746871f01ee09a8dac232524858d095480c2b20c10a03257c7feee0d", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/team/scenario/record.json": "b8ae088928e27c85b2046c51f7cd61f28843549dd2d83e35c74d72d2769026f5", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/team/scenario/source.md": "d21ef55d6d265f847f2ddbde0233f7552500f9b863b3620c3ebd55ea2e1e7517", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/team/task.json": "a8795b1bb437b5ba93f1c0488048578bf92dcc688cd51e957eeaed73e829657a", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/team/task.json": "ecd87f8f3edbda59da0480a2702cd7b01569352d824681cef07ae293402fa8fe", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/task.toml": "d40502d8b0efded14a88778118b9ce69bbabe566b52d0cbd43f0c807607dde37", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/task.toml": "ad922ceecc6cc549bb137d56fdccfc022d30ddbc0bd1345fdf32a391a2bdd409", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/tests/expected.json": "2ed0a4f276772162980dfe0ae5825abfbd6b08dc5bccc9774a057903a55a6760", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/tests/scenario/episode.yaml": "9608a536b76295582e0bb0d0c50fece4a3cc09e6d219562e95fe3844d4f032fd", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/tests/scenario/notes.md": "3729b3d2746871f01ee09a8dac232524858d095480c2b20c10a03257c7feee0d", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/tests/scenario/record.json": "b8ae088928e27c85b2046c51f7cd61f28843549dd2d83e35c74d72d2769026f5", @@ -3096,30 +3100,30 @@ "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/docker-compose.yaml": "f21a8d5ff8cd78f872fcaf35a9412eb3d63cc66bbc49e2fb746566ee311590ca", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/team/scenario/episode.yaml": "9608a536b76295582e0bb0d0c50fece4a3cc09e6d219562e95fe3844d4f032fd", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/team/scenario/notes.md": "3729b3d2746871f01ee09a8dac232524858d095480c2b20c10a03257c7feee0d", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/team/scenario/record.json": "b8ae088928e27c85b2046c51f7cd61f28843549dd2d83e35c74d72d2769026f5", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/team/scenario/source.md": "d21ef55d6d265f847f2ddbde0233f7552500f9b863b3620c3ebd55ea2e1e7517", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/team/task.json": "801ab9feac05be9c4de42272646d683e2d88260b639eb34ea055b85f5048aea9", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/team/task.json": "f47334b3c2ca6a6a78dc1d4ae40d601927346054f8c9464a71c606c6bab63da1", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/task.toml": "0df9cb0c02f9aded6e40622e40923edd9ddfb2291bfa55baeecdbb78fb54d35a", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/task.toml": "04eefb37d306563c8adbd0c44ebb5babed5512c9b929a711f8fecb5bf587111b", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/tests/expected.json": "6527ef72958e7428ba0933153deaff321eb0197f4f17d910c12a53557f3bd981", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/tests/scenario/episode.yaml": "9608a536b76295582e0bb0d0c50fece4a3cc09e6d219562e95fe3844d4f032fd", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/tests/scenario/notes.md": "3729b3d2746871f01ee09a8dac232524858d095480c2b20c10a03257c7feee0d", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/tests/scenario/record.json": "b8ae088928e27c85b2046c51f7cd61f28843549dd2d83e35c74d72d2769026f5", @@ -3138,30 +3142,30 @@ "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/docker-compose.yaml": "4088d135c8c22aab242183939cd6d4bdcf491d4295f9228dd72a1d9b1f47d03c", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/team/scenario/episode.yaml": "9608a536b76295582e0bb0d0c50fece4a3cc09e6d219562e95fe3844d4f032fd", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/team/scenario/notes.md": "3729b3d2746871f01ee09a8dac232524858d095480c2b20c10a03257c7feee0d", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/team/scenario/record.json": "b8ae088928e27c85b2046c51f7cd61f28843549dd2d83e35c74d72d2769026f5", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/team/scenario/source.md": "d21ef55d6d265f847f2ddbde0233f7552500f9b863b3620c3ebd55ea2e1e7517", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/team/task.json": "b486644cedd1a905eb65979f07a3dbbc8cf0bcb1e83007874d7095906dc4b279", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/team/task.json": "cc69ae72d296a92f755b8f4eb27cc1de195e2663a257ebf8c4069195aec26a18", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/task.toml": "398184ff1393e200cded5f3c17a957073e8006e087beae9cd88add40bd970a46", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/task.toml": "f9287e0db270873e494a6b5c32750b7263d8947541904bb0089c1d1c2e67c7bb", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/tests/expected.json": "7c140be914d25a34a54d3a671881979f75aa4c592ae4213e9f7f8c062a11300b", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/tests/scenario/episode.yaml": "9608a536b76295582e0bb0d0c50fece4a3cc09e6d219562e95fe3844d4f032fd", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/tests/scenario/notes.md": "3729b3d2746871f01ee09a8dac232524858d095480c2b20c10a03257c7feee0d", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/tests/scenario/record.json": "b8ae088928e27c85b2046c51f7cd61f28843549dd2d83e35c74d72d2769026f5", @@ -3180,30 +3184,30 @@ "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/docker-compose.yaml": "683d596715d83aadfe88bfd22067109ce79de9e14f9dbadc57f325fe1164afa6", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/team/scenario/episode.yaml": "9608a536b76295582e0bb0d0c50fece4a3cc09e6d219562e95fe3844d4f032fd", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/team/scenario/notes.md": "3729b3d2746871f01ee09a8dac232524858d095480c2b20c10a03257c7feee0d", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/team/scenario/record.json": "b8ae088928e27c85b2046c51f7cd61f28843549dd2d83e35c74d72d2769026f5", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/team/scenario/source.md": "d21ef55d6d265f847f2ddbde0233f7552500f9b863b3620c3ebd55ea2e1e7517", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/team/task.json": "32a81e49c1203bd8cabc891a024d00c201892c47bd0a8a231240724ced313d92", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/team/task.json": "9d4eda71aa3829f465a5519155977b832f08c3642a2c7696c2d5489aef5de6b7", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/task.toml": "1948914239d5a577149151927e1fe012f852bc931f24d213d540d41aedc410e4", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/task.toml": "4c8e037550e899ab5a990fb6b1e2b50872a460c82a7e3d298c5c022445d0d49a", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/tests/expected.json": "a54c95dfa473d57400bf25b9f7941ad38c1dca995d59ea23768791d172ca7263", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/tests/scenario/episode.yaml": "9608a536b76295582e0bb0d0c50fece4a3cc09e6d219562e95fe3844d4f032fd", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/tests/scenario/notes.md": "3729b3d2746871f01ee09a8dac232524858d095480c2b20c10a03257c7feee0d", "tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/tests/scenario/record.json": "b8ae088928e27c85b2046c51f7cd61f28843549dd2d83e35c74d72d2769026f5", @@ -3222,30 +3226,30 @@ "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/docker-compose.yaml": "68e6738b82cb6e3257e623609f48bf71a632863e8f649d199582a745834f91c5", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/team/scenario/episode.yaml": "da5fdd6c664ee6dd8008e981aee0875459218c898d29b52337eea850e1544344", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/team/scenario/notes.md": "3421e675b4a88d00ffb3d7cc61aa647602bec2b9f22008bded16ca318d345a27", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/team/scenario/record.json": "c71406c5b66af3cbcd945f572382d441493e8ffa236043b956576db604da7ca1", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/team/scenario/source.md": "123470ec85f64a59238668b2d62afebdc336274c0cbd1056306390ff6661145a", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/team/task.json": "56d529d63b2814747c1d26243ced6f8c704adc4f3dab3d224df9db72a7b40b5b", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/team/task.json": "26b458c35e65415bfe30f777ec3607465a908d9a1e08d634b6849eb2473d89f0", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/task.toml": "257608b1390489170c5c5437ce0e1e1517d5108d8d73a5f569f862cb9aef20e6", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/task.toml": "158a28f7382b1aa4a00b1d9315408e9f6383b953f1e499e394c2a22b02d9499d", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/tests/expected.json": "69036e9ec6b393223e4811855b3aed2cae0ce70cb479390296f6bf0502893698", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/tests/scenario/episode.yaml": "da5fdd6c664ee6dd8008e981aee0875459218c898d29b52337eea850e1544344", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/tests/scenario/notes.md": "3421e675b4a88d00ffb3d7cc61aa647602bec2b9f22008bded16ca318d345a27", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/tests/scenario/record.json": "c71406c5b66af3cbcd945f572382d441493e8ffa236043b956576db604da7ca1", @@ -3264,30 +3268,30 @@ "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/docker-compose.yaml": "e76e403dddd4692a58449b8587cd4f8fbfd1687029afe32927e24b91758a4f68", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/team/scenario/episode.yaml": "da5fdd6c664ee6dd8008e981aee0875459218c898d29b52337eea850e1544344", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/team/scenario/notes.md": "3421e675b4a88d00ffb3d7cc61aa647602bec2b9f22008bded16ca318d345a27", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/team/scenario/record.json": "c71406c5b66af3cbcd945f572382d441493e8ffa236043b956576db604da7ca1", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/team/scenario/source.md": "123470ec85f64a59238668b2d62afebdc336274c0cbd1056306390ff6661145a", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/team/task.json": "f42ef1c4585a54ed7d2ecf2f07e8e3bccb2039b4fe494926c06dea60aaff2901", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/team/task.json": "b62bb8be89769d7475165430dfd25f97f863b6f57c9bfa50ee9cc76a7ceed8c8", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/task.toml": "59a9ff42b21a2436f42876e6b7ad74b5e405e203938c8dbe7fb7e52d1f9f54b1", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/task.toml": "f1aaebe4cc50482a19c79ca02f3e727b7aeadda6137ce784aabcb5a6e82ffd01", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/tests/expected.json": "f2d125197fa353a1b3c57e68e8c0b9bb39bb818c0ac8548770dde85239990004", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/tests/scenario/episode.yaml": "da5fdd6c664ee6dd8008e981aee0875459218c898d29b52337eea850e1544344", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/tests/scenario/notes.md": "3421e675b4a88d00ffb3d7cc61aa647602bec2b9f22008bded16ca318d345a27", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/tests/scenario/record.json": "c71406c5b66af3cbcd945f572382d441493e8ffa236043b956576db604da7ca1", @@ -3306,30 +3310,30 @@ "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/docker-compose.yaml": "3702be0638b392b54cf15aef33433e9e22a77a67c877275b8286493a2e29441f", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/team/scenario/episode.yaml": "da5fdd6c664ee6dd8008e981aee0875459218c898d29b52337eea850e1544344", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/team/scenario/notes.md": "3421e675b4a88d00ffb3d7cc61aa647602bec2b9f22008bded16ca318d345a27", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/team/scenario/record.json": "c71406c5b66af3cbcd945f572382d441493e8ffa236043b956576db604da7ca1", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/team/scenario/source.md": "123470ec85f64a59238668b2d62afebdc336274c0cbd1056306390ff6661145a", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/team/task.json": "0f5dc37efbe95632cd39c89399ae54aca30d87bbc39259c2cc01f716a00425c2", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/team/task.json": "9b406a9cdfb2ea4a4cef5114e75b542f86b4db7abc5d08d4c508c1e86532f8c5", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/task.toml": "e0503482abd24872a14a917473477522d33558e437f2fcba7d046961e3de6b8e", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/task.toml": "72046eb4995a973b577056422190f593a1b253c7c20a55509b7d295ea07ecc56", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/tests/expected.json": "8c96debc4c7ce7cb39bd7d3a93e0cbf368245df5b2be811c3de1693bbce2de8e", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/tests/scenario/episode.yaml": "da5fdd6c664ee6dd8008e981aee0875459218c898d29b52337eea850e1544344", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/tests/scenario/notes.md": "3421e675b4a88d00ffb3d7cc61aa647602bec2b9f22008bded16ca318d345a27", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/tests/scenario/record.json": "c71406c5b66af3cbcd945f572382d441493e8ffa236043b956576db604da7ca1", @@ -3348,30 +3352,30 @@ "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/docker-compose.yaml": "0ce706bf2684639e54136f59553f09a2460c4cbef3039de2968b2fb323134096", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/team/scenario/episode.yaml": "da5fdd6c664ee6dd8008e981aee0875459218c898d29b52337eea850e1544344", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/team/scenario/notes.md": "3421e675b4a88d00ffb3d7cc61aa647602bec2b9f22008bded16ca318d345a27", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/team/scenario/record.json": "c71406c5b66af3cbcd945f572382d441493e8ffa236043b956576db604da7ca1", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/team/scenario/source.md": "123470ec85f64a59238668b2d62afebdc336274c0cbd1056306390ff6661145a", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/team/task.json": "8a0da53cb9e4abb0be34157e42d5aeee3cf4c769b19efbc8d932e63b0404df73", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/team/task.json": "1ffd73da5510f2a0b32d45ea4b2e5a1c541789dc1d47767d813c740105110078", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/task.toml": "5ad7b451c8a558f309ea156187ec1adb6cdcc0a3a48e06a132aaffee86e6768f", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/task.toml": "59fd3bc9af259cfce7954e467f6003e70624709c54f5254ee820601ac11f1ad5", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/tests/expected.json": "feca8700027e40c584fd1dc7e1b79e7f06ede0144719e78d1a2bb8c9a49cc817", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/tests/scenario/episode.yaml": "da5fdd6c664ee6dd8008e981aee0875459218c898d29b52337eea850e1544344", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/tests/scenario/notes.md": "3421e675b4a88d00ffb3d7cc61aa647602bec2b9f22008bded16ca318d345a27", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/tests/scenario/record.json": "c71406c5b66af3cbcd945f572382d441493e8ffa236043b956576db604da7ca1", @@ -3390,30 +3394,30 @@ "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/docker-compose.yaml": "e928067297d88b4ed318ed12ca8bf801e83769ffdebdf16da75f5e8852ddb5b7", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/team/scenario/episode.yaml": "da5fdd6c664ee6dd8008e981aee0875459218c898d29b52337eea850e1544344", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/team/scenario/notes.md": "3421e675b4a88d00ffb3d7cc61aa647602bec2b9f22008bded16ca318d345a27", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/team/scenario/record.json": "c71406c5b66af3cbcd945f572382d441493e8ffa236043b956576db604da7ca1", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/team/scenario/source.md": "123470ec85f64a59238668b2d62afebdc336274c0cbd1056306390ff6661145a", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/team/task.json": "2cf10b642906d5e38297cf4d0772c4228f537725cf7f0248736597095d42f3f7", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/team/task.json": "a19ed904f0b18e839c52afb8d8e4782548d0eabdd672ae16c2a1189ee07ade7f", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/task.toml": "199a634c95c1ad3e91f56bec2d75835b13f251807d5f84ef7e98255f913c2445", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/task.toml": "d063a728abf7a1d13e076d73a6121a9a9c3d8aa8222a3adc22d1f06f86b3ba35", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/tests/expected.json": "10598583ab758eac71eb0182b9ecbd7e82b3cbead906bcf0b1e5ba3549ad5874", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/tests/scenario/episode.yaml": "da5fdd6c664ee6dd8008e981aee0875459218c898d29b52337eea850e1544344", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/tests/scenario/notes.md": "3421e675b4a88d00ffb3d7cc61aa647602bec2b9f22008bded16ca318d345a27", "tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/tests/scenario/record.json": "c71406c5b66af3cbcd945f572382d441493e8ffa236043b956576db604da7ca1", @@ -3432,30 +3436,30 @@ "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/docker-compose.yaml": "3ee13f6d67d2c33131109d64b9c2dc210e496e8468aee0baa99d48adbc5c6d26", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/team/scenario/episode.yaml": "99a6900abd585c3d2765f4eb09d9582392431dcef81d9c270551194176c4579b", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/team/scenario/notes.md": "e103e567128a979d307f888a2da9494fe2c2880769333f168bdcb659d0292fbf", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/team/scenario/record.json": "9975eb3ea5e1bd175587483c610b43fdd9e1c3ab1fe0add492c260842dd405ef", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/team/scenario/source.md": "fd0573724722b05c2011fd863aff604b6d8908b92fdc69aff508ccf442e763d3", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/team/task.json": "b19a5c3ef21b39ef5722aa3c5c0c46de21390e14f7421f29b07883ec6bf8823e", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/team/task.json": "77f60aa9a73c900e090ff43b1f60fa5026a03366ff7b5a74564ba7acd766e05f", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/task.toml": "101a101437ef3bcf7be91bacebeb96c4405b0167e20940f171d92866f9fb49d1", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/task.toml": "1af42849aadbd609b08698d9f88a7936c4f9a4c1501e488efc7734ea7df5f754", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/tests/expected.json": "f63c9052b0d0476ce921406d5e52c29b1891d3d0bcff14053bbfbcd4dc8cb511", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/tests/scenario/episode.yaml": "99a6900abd585c3d2765f4eb09d9582392431dcef81d9c270551194176c4579b", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/tests/scenario/notes.md": "e103e567128a979d307f888a2da9494fe2c2880769333f168bdcb659d0292fbf", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/tests/scenario/record.json": "9975eb3ea5e1bd175587483c610b43fdd9e1c3ab1fe0add492c260842dd405ef", @@ -3474,30 +3478,30 @@ "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/docker-compose.yaml": "2d5c24a4cbcacf2fe757ebdbe896d8d754f767b6c16b073562d3b4c605d1c8d4", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/team/scenario/episode.yaml": "99a6900abd585c3d2765f4eb09d9582392431dcef81d9c270551194176c4579b", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/team/scenario/notes.md": "e103e567128a979d307f888a2da9494fe2c2880769333f168bdcb659d0292fbf", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/team/scenario/record.json": "9975eb3ea5e1bd175587483c610b43fdd9e1c3ab1fe0add492c260842dd405ef", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/team/scenario/source.md": "fd0573724722b05c2011fd863aff604b6d8908b92fdc69aff508ccf442e763d3", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/team/task.json": "4d6cbcccb6119340b4af05c63d814e0b19155c9173c081fcad4932963ff41516", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/team/task.json": "3cc0490b691d9cc82d070cdcb81493949e7fe49242e0f7eb37ef8ba0be7b2ccd", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/task.toml": "8e9b30f43a01cf1d0298d968c55a7a51862989d25083332ff031191616eb69e6", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/task.toml": "27c1f72bd09fcc275942425d26888d5b6960704e61c14d4751fc3b843cc4690c", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/tests/expected.json": "f13d9d5a19bef03deecedd588a21cdbc570a59ad34a5ec67a0235d66659b6e9b", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/tests/scenario/episode.yaml": "99a6900abd585c3d2765f4eb09d9582392431dcef81d9c270551194176c4579b", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/tests/scenario/notes.md": "e103e567128a979d307f888a2da9494fe2c2880769333f168bdcb659d0292fbf", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/tests/scenario/record.json": "9975eb3ea5e1bd175587483c610b43fdd9e1c3ab1fe0add492c260842dd405ef", @@ -3516,30 +3520,30 @@ "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/docker-compose.yaml": "a16d7f5eaf53cda4e2f6a37666da9ceaa064281732a232a122b2d1b6072405f1", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/team/scenario/episode.yaml": "99a6900abd585c3d2765f4eb09d9582392431dcef81d9c270551194176c4579b", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/team/scenario/notes.md": "e103e567128a979d307f888a2da9494fe2c2880769333f168bdcb659d0292fbf", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/team/scenario/record.json": "9975eb3ea5e1bd175587483c610b43fdd9e1c3ab1fe0add492c260842dd405ef", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/team/scenario/source.md": "fd0573724722b05c2011fd863aff604b6d8908b92fdc69aff508ccf442e763d3", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/team/task.json": "efe4052bef1ebbd59adf08886e78ea61ca85915123783ac9fcef62b49ac45391", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/team/task.json": "7410e97f53f65171e7eeb32c4b772538d645c93dd4872533ec76af255f6b90c3", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/task.toml": "7ffec894316059884443c7e75f3f63ddbc5d26457846e3e260834b06a9a2e20b", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/task.toml": "ca17132b496a76a2b40be609ecf6c172593a62e89e9d720264a828ae645ee8ad", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/tests/expected.json": "35dfb12c705175bcdc9cd9f17073834903dbe638a7a9beff1e0b7373bc51a5e9", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/tests/scenario/episode.yaml": "99a6900abd585c3d2765f4eb09d9582392431dcef81d9c270551194176c4579b", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/tests/scenario/notes.md": "e103e567128a979d307f888a2da9494fe2c2880769333f168bdcb659d0292fbf", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/tests/scenario/record.json": "9975eb3ea5e1bd175587483c610b43fdd9e1c3ab1fe0add492c260842dd405ef", @@ -3558,30 +3562,30 @@ "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/docker-compose.yaml": "5ea4a4db741638b873f272eacadaf490c087a777c43d791c4111762ea661c0a6", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/team/scenario/episode.yaml": "99a6900abd585c3d2765f4eb09d9582392431dcef81d9c270551194176c4579b", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/team/scenario/notes.md": "e103e567128a979d307f888a2da9494fe2c2880769333f168bdcb659d0292fbf", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/team/scenario/record.json": "9975eb3ea5e1bd175587483c610b43fdd9e1c3ab1fe0add492c260842dd405ef", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/team/scenario/source.md": "fd0573724722b05c2011fd863aff604b6d8908b92fdc69aff508ccf442e763d3", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/team/task.json": "b7f0e8a7423284bacc1a098879e811c135ca11c2354e826f5b6a61e93d292c02", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/team/task.json": "9f63752180d0cb82537b94e652b36ac9662341a4901df35712433ce4663e8bf0", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/task.toml": "5d8f8b192d9b4031da680ca86d64668f02f169d41698e8de386a17be7110d8dc", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/task.toml": "0769c5b62443c85eb59a3289f170f3302e29b65396403aa3348ec295b9456bab", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/tests/expected.json": "13fedc2b050c16c88179598bc5fca246bfc5c9889f294418b0f088ebac06c6c5", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/tests/scenario/episode.yaml": "99a6900abd585c3d2765f4eb09d9582392431dcef81d9c270551194176c4579b", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/tests/scenario/notes.md": "e103e567128a979d307f888a2da9494fe2c2880769333f168bdcb659d0292fbf", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/tests/scenario/record.json": "9975eb3ea5e1bd175587483c610b43fdd9e1c3ab1fe0add492c260842dd405ef", @@ -3600,30 +3604,30 @@ "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/docker-compose.yaml": "5bba36983d7e86207e4e1b58b347529109b86b9ba25f06636743e0fdc060b00a", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/team/scenario/episode.yaml": "99a6900abd585c3d2765f4eb09d9582392431dcef81d9c270551194176c4579b", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/team/scenario/notes.md": "e103e567128a979d307f888a2da9494fe2c2880769333f168bdcb659d0292fbf", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/team/scenario/record.json": "9975eb3ea5e1bd175587483c610b43fdd9e1c3ab1fe0add492c260842dd405ef", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/team/scenario/source.md": "fd0573724722b05c2011fd863aff604b6d8908b92fdc69aff508ccf442e763d3", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/team/task.json": "04b44b05e76ef64bf4b33300250302523ffd419640a117f8c908610ce5b7b685", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/team/task.json": "5a9e03e57de6e319588ebb746ad4088a248ae8a55a84616e273e7ef61beaba61", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/task.toml": "23a4df64c46f7e7a24dfdc5e7df0173a464646f872255437b156dce58e0b024c", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/task.toml": "8a4531cf78c6e764a6639fda72954de0976eea1f04fe050e1d1467c6c9e2afe2", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/tests/expected.json": "44bd3e06d1432bccb71832e296845db25957ed64fc308ed584e8107bb5bc81e4", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/tests/scenario/episode.yaml": "99a6900abd585c3d2765f4eb09d9582392431dcef81d9c270551194176c4579b", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/tests/scenario/notes.md": "e103e567128a979d307f888a2da9494fe2c2880769333f168bdcb659d0292fbf", "tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/tests/scenario/record.json": "9975eb3ea5e1bd175587483c610b43fdd9e1c3ab1fe0add492c260842dd405ef", @@ -3642,30 +3646,30 @@ "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/docker-compose.yaml": "ccd07759acc36d023927ad9db7d267da0890824d4efa8d6bebfd5071a6b98a9e", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/team/scenario/episode.yaml": "9380451fb42c114cebc02379f590a93814dac3335f7704a440f2de4d40415d61", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/team/scenario/notes.md": "8421f397280db61d9c09485452d6026968c965d4e89d33aebf759ac8032b1077", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/team/scenario/record.json": "f1f16e767f16326306d7666a1ce9535a407e7d87ac96f682260ed48cb9467b7a", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/team/scenario/source.md": "548fe45d52fce180caeb3f5e1aa41dc2ec166d4482e45b47772b354f64d30b59", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/team/task.json": "37209f596a367d9d46cb6b76b949ee5781d380dd3e4be7d8549675a4c3abf1b5", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/team/task.json": "e934e9a595de8043ee4cc904c537f01f7bc85ec151989b696408fee6fc8430e4", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/task.toml": "d4643aafa8fa18baf982faf5ff6267b507f6e042cf22d8fc369a96aeef80f0b1", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/task.toml": "1b36188304327d483b8187fe4406ece38d3aa8c5c5dbbb542c28562bca65c627", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/tests/expected.json": "6ec67639e6cf361265412a5c373e8272823a0c0680fdde5c6330510bd2ab76ce", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/tests/scenario/episode.yaml": "9380451fb42c114cebc02379f590a93814dac3335f7704a440f2de4d40415d61", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/tests/scenario/notes.md": "8421f397280db61d9c09485452d6026968c965d4e89d33aebf759ac8032b1077", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/tests/scenario/record.json": "f1f16e767f16326306d7666a1ce9535a407e7d87ac96f682260ed48cb9467b7a", @@ -3684,30 +3688,30 @@ "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/docker-compose.yaml": "efaa933511e74ba1286850e5985d67cbd67c17f6e2f0b70e10bd28c80500cd52", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/team/scenario/episode.yaml": "9380451fb42c114cebc02379f590a93814dac3335f7704a440f2de4d40415d61", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/team/scenario/notes.md": "8421f397280db61d9c09485452d6026968c965d4e89d33aebf759ac8032b1077", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/team/scenario/record.json": "f1f16e767f16326306d7666a1ce9535a407e7d87ac96f682260ed48cb9467b7a", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/team/scenario/source.md": "548fe45d52fce180caeb3f5e1aa41dc2ec166d4482e45b47772b354f64d30b59", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/team/task.json": "8404ee66feda9448285a46b74046cdaab07e93df2c6bfd1be6291f63f0035937", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/team/task.json": "1ad4b3a4721bcef29aecab4ee8480cb9d22cb2ac387b946fb10e23f4a5460260", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/task.toml": "4063e6cee04e6072525c0676bb9ad12c26a388fa811e4fb1d54fc143901e697d", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/task.toml": "16ac6ce6e96c0caa5295c3abcbcdd6b0d36859b3cad62bdc1ede292d7ef4dd95", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/tests/expected.json": "031b5322b732ba07952fc952627f46e3fdd3f72236515bea13be52c0d1de650d", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/tests/scenario/episode.yaml": "9380451fb42c114cebc02379f590a93814dac3335f7704a440f2de4d40415d61", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/tests/scenario/notes.md": "8421f397280db61d9c09485452d6026968c965d4e89d33aebf759ac8032b1077", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/tests/scenario/record.json": "f1f16e767f16326306d7666a1ce9535a407e7d87ac96f682260ed48cb9467b7a", @@ -3726,30 +3730,30 @@ "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/docker-compose.yaml": "037b841de2c2c610c539f7a94ce6803aae54994d2bad8663bc381eee3043a7c0", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/team/scenario/episode.yaml": "9380451fb42c114cebc02379f590a93814dac3335f7704a440f2de4d40415d61", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/team/scenario/notes.md": "8421f397280db61d9c09485452d6026968c965d4e89d33aebf759ac8032b1077", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/team/scenario/record.json": "f1f16e767f16326306d7666a1ce9535a407e7d87ac96f682260ed48cb9467b7a", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/team/scenario/source.md": "548fe45d52fce180caeb3f5e1aa41dc2ec166d4482e45b47772b354f64d30b59", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/team/task.json": "3fbabb44f1f528dd6cca30f639eb09d8c0152190cc9a89d8c62532c0696e90b2", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/team/task.json": "07eb783c1f71250213f74494004b4a4cc75e8ef6b4e3add5e39d19798e62dfdc", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/task.toml": "bac32973dd9dd8add2c63fc036b9e43cb99bb9dfd1ae979cb7f167db6d10ff9e", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/task.toml": "ce2b9723ba081d2a52f6c404a85acf23a42c66290269f9daca09c512a0c7f21c", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/tests/expected.json": "f22e01c819d0e7fd69801f8024cb97654ee6749039a7d0a25e806cb6fbfaae8a", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/tests/scenario/episode.yaml": "9380451fb42c114cebc02379f590a93814dac3335f7704a440f2de4d40415d61", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/tests/scenario/notes.md": "8421f397280db61d9c09485452d6026968c965d4e89d33aebf759ac8032b1077", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/tests/scenario/record.json": "f1f16e767f16326306d7666a1ce9535a407e7d87ac96f682260ed48cb9467b7a", @@ -3768,30 +3772,30 @@ "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/docker-compose.yaml": "1b99c2df0b22df6cb257e1f807a51cc63e48b00020d760e4654992d8cf2963cf", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/team/scenario/episode.yaml": "9380451fb42c114cebc02379f590a93814dac3335f7704a440f2de4d40415d61", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/team/scenario/notes.md": "8421f397280db61d9c09485452d6026968c965d4e89d33aebf759ac8032b1077", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/team/scenario/record.json": "f1f16e767f16326306d7666a1ce9535a407e7d87ac96f682260ed48cb9467b7a", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/team/scenario/source.md": "548fe45d52fce180caeb3f5e1aa41dc2ec166d4482e45b47772b354f64d30b59", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/team/task.json": "b142d639f1be8b4edcced75c969e74c214afad2dc82b5ec10e792e2028dab8be", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/team/task.json": "65c83ea2be588677651f3dfa3de49dda5a1b70ec2a14afa38d51af822143d8db", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/task.toml": "d1b975e7e59fd5c43c3a418ae1c9c887bda79e9fd0cd5581e56a900b313369b7", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/task.toml": "60a18f4cdd40af785d3e91f606e511e6998edad0ac09bc8f261870a2b7fea6b1", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/tests/expected.json": "617fea288f5e20648c21619211d1640fc194de4dae96ebf0d7d6d70833d51edd", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/tests/scenario/episode.yaml": "9380451fb42c114cebc02379f590a93814dac3335f7704a440f2de4d40415d61", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/tests/scenario/notes.md": "8421f397280db61d9c09485452d6026968c965d4e89d33aebf759ac8032b1077", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/tests/scenario/record.json": "f1f16e767f16326306d7666a1ce9535a407e7d87ac96f682260ed48cb9467b7a", @@ -3810,30 +3814,30 @@ "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/docker-compose.yaml": "ce3ea6c48b34a2587a583297fc0ae2da4d69793608fd67a352b7f5ac03974123", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/team/scenario/episode.yaml": "9380451fb42c114cebc02379f590a93814dac3335f7704a440f2de4d40415d61", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/team/scenario/notes.md": "8421f397280db61d9c09485452d6026968c965d4e89d33aebf759ac8032b1077", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/team/scenario/record.json": "f1f16e767f16326306d7666a1ce9535a407e7d87ac96f682260ed48cb9467b7a", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/team/scenario/source.md": "548fe45d52fce180caeb3f5e1aa41dc2ec166d4482e45b47772b354f64d30b59", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/team/task.json": "5880f4d990f336847698d63d6aff7180f0370b7e36fbe0de3737785ae8c4e480", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/team/task.json": "ebfeb220e0ab8a8dcdf546dab12cc2e5d06e0031cd3de0a6e0832be2f5cee721", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/task.toml": "df35e5acf97f91470455a51eeb65f57207dd8c084d76a246737fe8a11f036fa0", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/task.toml": "207234b6dc65f942b29a450b04e3442b0c08db0f2edf570ab5ae0b041872c0a7", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/tests/expected.json": "4763d6cf614bad655593e231db261f00c86da98d99f2fda53ebf09e5e832baf7", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/tests/scenario/episode.yaml": "9380451fb42c114cebc02379f590a93814dac3335f7704a440f2de4d40415d61", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/tests/scenario/notes.md": "8421f397280db61d9c09485452d6026968c965d4e89d33aebf759ac8032b1077", "tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/tests/scenario/record.json": "f1f16e767f16326306d7666a1ce9535a407e7d87ac96f682260ed48cb9467b7a", @@ -3852,30 +3856,30 @@ "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/docker-compose.yaml": "0ad53858192ed0bebb1290ff7cd20708179a6bd7e880849f20711ec244056eed", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/team/scenario/episode.yaml": "9e12554fa5e934c51f8716abca976b5a73fa989c5087e5c67989bf30c97419f2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/team/scenario/notes.md": "1266710cf0386326d978f59f0e52fbf441d35f4b3aa06d08161072ca81195d37", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/team/scenario/record.json": "222bb7b174919ed5da3a7c719aacd0826f0581b01ce39164667f4b749209667b", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/team/scenario/source.md": "bebb8b5aa119f3a971ba98f5dc41169d597ec306aab57e8fba76a9206ea20229", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/team/task.json": "9c7a380e33e87288fc179d65144e8df643a7ba63a49813fb200275330d7fba2e", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/team/task.json": "2f3d5fe07e76a55c97e1336f080f672f9f2249d513ceb1c1985958017ffdaeed", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/task.toml": "bf90eca3d8b1c65db7937b39ba46e39d1117a3a5f4c79bd9fd812b8dd9646ec6", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/task.toml": "b0eaec8222735e3041abdc613b3e8aca744ad075b03049b9a46b5cec0c536e16", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/tests/expected.json": "304ecc143fd2d9341932d2b3361ce9bc72fa2a7f77345b23bdbe45fee3711675", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/tests/scenario/episode.yaml": "9e12554fa5e934c51f8716abca976b5a73fa989c5087e5c67989bf30c97419f2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/tests/scenario/notes.md": "1266710cf0386326d978f59f0e52fbf441d35f4b3aa06d08161072ca81195d37", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/tests/scenario/record.json": "222bb7b174919ed5da3a7c719aacd0826f0581b01ce39164667f4b749209667b", @@ -3894,30 +3898,30 @@ "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/docker-compose.yaml": "f0dfdf91c11685fb63c820f0092013a25b8fc70924266f152985d7b2541abb0a", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/team/scenario/episode.yaml": "9e12554fa5e934c51f8716abca976b5a73fa989c5087e5c67989bf30c97419f2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/team/scenario/notes.md": "1266710cf0386326d978f59f0e52fbf441d35f4b3aa06d08161072ca81195d37", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/team/scenario/record.json": "222bb7b174919ed5da3a7c719aacd0826f0581b01ce39164667f4b749209667b", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/team/scenario/source.md": "bebb8b5aa119f3a971ba98f5dc41169d597ec306aab57e8fba76a9206ea20229", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/team/task.json": "d4ca38e707d1b59276b233e469161c726b63c282ceb13c9b7b0fe1cc3b087719", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/team/task.json": "eea9745f44f2cd30390e0c8b19199e343b4b39afe1be62c53331cab6b36de020", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/task.toml": "5154a7d046094895bc338797ae58ec438cb7c0bbd473bb749982e07bf2e38213", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/task.toml": "f70d3e8a568d5f59c41a30ee2d9b5a9692f52b09bc291f296821b6824b671df7", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/tests/expected.json": "d96e86aa9d65cff5b5508bb1dc5021e815a0dd6277e970a23d58e89c4ab54132", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/tests/scenario/episode.yaml": "9e12554fa5e934c51f8716abca976b5a73fa989c5087e5c67989bf30c97419f2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/tests/scenario/notes.md": "1266710cf0386326d978f59f0e52fbf441d35f4b3aa06d08161072ca81195d37", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/tests/scenario/record.json": "222bb7b174919ed5da3a7c719aacd0826f0581b01ce39164667f4b749209667b", @@ -3936,30 +3940,30 @@ "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/docker-compose.yaml": "ffb2d93652db20a2e3d7c127715a34427479dfa2d5eec7df0ee1222d3c4eaceb", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/team/scenario/episode.yaml": "9e12554fa5e934c51f8716abca976b5a73fa989c5087e5c67989bf30c97419f2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/team/scenario/notes.md": "1266710cf0386326d978f59f0e52fbf441d35f4b3aa06d08161072ca81195d37", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/team/scenario/record.json": "222bb7b174919ed5da3a7c719aacd0826f0581b01ce39164667f4b749209667b", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/team/scenario/source.md": "bebb8b5aa119f3a971ba98f5dc41169d597ec306aab57e8fba76a9206ea20229", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/team/task.json": "1e5f05f0d17feaf572d994c9a8a096dab21edc5cb9145e232c4a5c95a8b80fdd", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/team/task.json": "83b84808d996ed7b2ae9884c71aed64e3a485ef57565862db9bcf7e65161e6c1", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/task.toml": "f2c20cb5df16b01273ac574363b6a7f5048034c34609c712629caa8ca41cfd9d", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/task.toml": "a19299ee891ff978c7b552d5c596b75008f8dda2b646348b8fa099ae0b18a8ae", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/tests/expected.json": "3a96277556694c831ffc36cb488536c7701cfa4b10b0fb6834130640bb24a17a", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/tests/scenario/episode.yaml": "9e12554fa5e934c51f8716abca976b5a73fa989c5087e5c67989bf30c97419f2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/tests/scenario/notes.md": "1266710cf0386326d978f59f0e52fbf441d35f4b3aa06d08161072ca81195d37", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/tests/scenario/record.json": "222bb7b174919ed5da3a7c719aacd0826f0581b01ce39164667f4b749209667b", @@ -3978,30 +3982,30 @@ "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/docker-compose.yaml": "d941822e29ba9bc266bed5d252b83ddf419792a5735e3bb06e8d713bf54289d0", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/team/scenario/episode.yaml": "9e12554fa5e934c51f8716abca976b5a73fa989c5087e5c67989bf30c97419f2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/team/scenario/notes.md": "1266710cf0386326d978f59f0e52fbf441d35f4b3aa06d08161072ca81195d37", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/team/scenario/record.json": "222bb7b174919ed5da3a7c719aacd0826f0581b01ce39164667f4b749209667b", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/team/scenario/source.md": "bebb8b5aa119f3a971ba98f5dc41169d597ec306aab57e8fba76a9206ea20229", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/team/task.json": "056b63c8079abf35c7419e2a055cf39081c8940aadfc8d5ee4f0ca684cc9e33a", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/team/task.json": "63f2c925381854dd7045fac4dd28adaa7bce07f96531fac8db5219c3d171bc54", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/task.toml": "6e0bb7f91940c5a65b3f3aae7962fc0b05aae3d3cc89ba121349227374922a05", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/task.toml": "972920c284fd49e3f91529abeb64f5cecea12e6631b88ffae3584687189ab0e5", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/tests/expected.json": "32e19921468fdc386a51342a62d0da710b5158a70a3f9194bfe3e8a43739a620", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/tests/scenario/episode.yaml": "9e12554fa5e934c51f8716abca976b5a73fa989c5087e5c67989bf30c97419f2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/tests/scenario/notes.md": "1266710cf0386326d978f59f0e52fbf441d35f4b3aa06d08161072ca81195d37", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/tests/scenario/record.json": "222bb7b174919ed5da3a7c719aacd0826f0581b01ce39164667f4b749209667b", @@ -4020,30 +4024,30 @@ "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/docker-compose.yaml": "5cf10f24a2afe56110c2f0fcdeff74cbc0bbbac9798acb4b6593384e54683dc3", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/team/scenario/episode.yaml": "9e12554fa5e934c51f8716abca976b5a73fa989c5087e5c67989bf30c97419f2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/team/scenario/notes.md": "1266710cf0386326d978f59f0e52fbf441d35f4b3aa06d08161072ca81195d37", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/team/scenario/record.json": "222bb7b174919ed5da3a7c719aacd0826f0581b01ce39164667f4b749209667b", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/team/scenario/source.md": "bebb8b5aa119f3a971ba98f5dc41169d597ec306aab57e8fba76a9206ea20229", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/team/task.json": "436c1ac24057cad9aae31d47c78bbb87a841a521512c7116437d719cfb8325e6", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/team/task.json": "dc57a8e8c5f50afcabe11edf4c52d11dea263d3149e28eea31290358fdb3d78c", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/task.toml": "67fa2d84177ecc4a42cef2121727b9009619a36c46487024d382e1d315fb0bee", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/task.toml": "6b464b64401ccf35407f9a428fcd47df8f071bae8032776d3976de3794f7995e", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/tests/expected.json": "7f7bc24743100564451c27196eb610d8b875645b40765882eadb8200d2e1dcd8", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/tests/scenario/episode.yaml": "9e12554fa5e934c51f8716abca976b5a73fa989c5087e5c67989bf30c97419f2", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/tests/scenario/notes.md": "1266710cf0386326d978f59f0e52fbf441d35f4b3aa06d08161072ca81195d37", "tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/tests/scenario/record.json": "222bb7b174919ed5da3a7c719aacd0826f0581b01ce39164667f4b749209667b", @@ -4062,30 +4066,30 @@ "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/docker-compose.yaml": "b61d39758cc3643465b405e70bd1f5958c8be1366b7740cb520d63e3e7fcc634", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/team/scenario/episode.yaml": "736a8cc6a7ba18c175fccdddde1f10a1e3440d5bd0bf80594ad5e3abaf05b623", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/team/scenario/notes.md": "2c67451929a289e453a5000b7db263e9e40add97d7ad9a1009bafbe2f0b9e972", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/team/scenario/record.json": "cc5828513fe66db32dd7ddc327a87cb6fd53a463f264a178176a512eea4a9069", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/team/scenario/source.md": "4f9a0b319ba8d16939b017626015676e186c48f234ba7bf764f9c2d967ff6687", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/team/task.json": "6e0e7f5ff6a86b9f0c148f0e258e09c8751f36a1e75331bb92b7fe1145320849", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/team/task.json": "7c9555ae9cea704bb84dc478fdfa934aa62e5602581b828f78f740638bb1f031", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/task.toml": "5e5b2020ae047f7fa48ab72610a5846aaced7374699c2367ac47f7209d31f9c9", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/task.toml": "b72ad35ee1d0b673426f2d28b1885c27bf9ff028a3333d1b0ff3e0db778db413", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/tests/expected.json": "0a94ea15f62af6236492019e847dd2cd871fa812103c47b06488a30324b9b974", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/tests/scenario/episode.yaml": "736a8cc6a7ba18c175fccdddde1f10a1e3440d5bd0bf80594ad5e3abaf05b623", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/tests/scenario/notes.md": "2c67451929a289e453a5000b7db263e9e40add97d7ad9a1009bafbe2f0b9e972", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/tests/scenario/record.json": "cc5828513fe66db32dd7ddc327a87cb6fd53a463f264a178176a512eea4a9069", @@ -4104,30 +4108,30 @@ "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/docker-compose.yaml": "02ec63a4df9716134f56b9285e179b664ae1ae7328a15a3f8e04829366a5f387", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/team/scenario/episode.yaml": "736a8cc6a7ba18c175fccdddde1f10a1e3440d5bd0bf80594ad5e3abaf05b623", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/team/scenario/notes.md": "2c67451929a289e453a5000b7db263e9e40add97d7ad9a1009bafbe2f0b9e972", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/team/scenario/record.json": "cc5828513fe66db32dd7ddc327a87cb6fd53a463f264a178176a512eea4a9069", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/team/scenario/source.md": "4f9a0b319ba8d16939b017626015676e186c48f234ba7bf764f9c2d967ff6687", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/team/task.json": "2fa908e7d1251987e8cfefea233ef2622e00c583d59c615b9d0e66f9ac5ebc83", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/team/task.json": "58a454ec380b921d2c0836eb8a18ccc6666e2afdd8e9f2c1619dbd8614958287", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/task.toml": "cefa5f4fcca40b767713469145e0945d435bf95066923661beed9611e56f4406", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/task.toml": "659cf9d9aba4409ed715ca8475b18f5fbef82ada8690f5ae0d556b66680a8ac9", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/tests/expected.json": "26e9293138de4f1129aec22e2d353dc265af22767ef51a44455afa5b282ea8e5", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/tests/scenario/episode.yaml": "736a8cc6a7ba18c175fccdddde1f10a1e3440d5bd0bf80594ad5e3abaf05b623", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/tests/scenario/notes.md": "2c67451929a289e453a5000b7db263e9e40add97d7ad9a1009bafbe2f0b9e972", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/tests/scenario/record.json": "cc5828513fe66db32dd7ddc327a87cb6fd53a463f264a178176a512eea4a9069", @@ -4146,30 +4150,30 @@ "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/docker-compose.yaml": "7d1699a47f3a281b400f253061554533076e2b44be310f140b577ff2c7129fca", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/team/scenario/episode.yaml": "736a8cc6a7ba18c175fccdddde1f10a1e3440d5bd0bf80594ad5e3abaf05b623", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/team/scenario/notes.md": "2c67451929a289e453a5000b7db263e9e40add97d7ad9a1009bafbe2f0b9e972", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/team/scenario/record.json": "cc5828513fe66db32dd7ddc327a87cb6fd53a463f264a178176a512eea4a9069", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/team/scenario/source.md": "4f9a0b319ba8d16939b017626015676e186c48f234ba7bf764f9c2d967ff6687", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/team/task.json": "f22e489826bb1aa309f060e9e5c856597a15cfd4d61f652132c2f8d66d309695", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/team/task.json": "7b058a2ac0abd9ef0ecd2aa053e4d4bfd5ffacedb4ff5592ed7762b14c741400", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/task.toml": "65b2e39a1031ab8cfd853602bb2444a7272b3f4061acb7ae6dd8519eddf296c1", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/task.toml": "c787e9d9d62a704eabe4b2b39187bbe5009ea54a64b7fe7db57b6f66c8cf347e", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/tests/expected.json": "ae79756956b18223ddc6f42133e070015d4858e1f848442df1b1c27850b70c74", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/tests/scenario/episode.yaml": "736a8cc6a7ba18c175fccdddde1f10a1e3440d5bd0bf80594ad5e3abaf05b623", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/tests/scenario/notes.md": "2c67451929a289e453a5000b7db263e9e40add97d7ad9a1009bafbe2f0b9e972", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/tests/scenario/record.json": "cc5828513fe66db32dd7ddc327a87cb6fd53a463f264a178176a512eea4a9069", @@ -4188,30 +4192,30 @@ "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/docker-compose.yaml": "13f95efc05e55dfb50ca399409e2599c81ee06e6887287d9a811a2dff86a42f7", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/team/scenario/episode.yaml": "736a8cc6a7ba18c175fccdddde1f10a1e3440d5bd0bf80594ad5e3abaf05b623", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/team/scenario/notes.md": "2c67451929a289e453a5000b7db263e9e40add97d7ad9a1009bafbe2f0b9e972", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/team/scenario/record.json": "cc5828513fe66db32dd7ddc327a87cb6fd53a463f264a178176a512eea4a9069", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/team/scenario/source.md": "4f9a0b319ba8d16939b017626015676e186c48f234ba7bf764f9c2d967ff6687", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/team/task.json": "15e04e358eb8a08984d4c72ff9c4ca59909343376e8e7b753e439b7ac3a843be", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/team/task.json": "cc57635bbb3375c69ad4f8e31bb21b2b9871cd11019c9b85d774b545a09cf7c8", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/task.toml": "f42ceb1d2e9b788d4ee48e75fabdb8ca45350696c3e30cfb19f692595f9b34fd", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/task.toml": "b91f31f277b0942b053ec4645e221c4708843cff2ba3b74423215e8367f4c687", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/tests/expected.json": "9f920e81914ddc4c719b7317de38d725beaa8af4467b8a4da67a7f48eb9327d0", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/tests/scenario/episode.yaml": "736a8cc6a7ba18c175fccdddde1f10a1e3440d5bd0bf80594ad5e3abaf05b623", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/tests/scenario/notes.md": "2c67451929a289e453a5000b7db263e9e40add97d7ad9a1009bafbe2f0b9e972", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/tests/scenario/record.json": "cc5828513fe66db32dd7ddc327a87cb6fd53a463f264a178176a512eea4a9069", @@ -4230,30 +4234,30 @@ "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/docker-compose.yaml": "b9499b864514c01c75034e11db5aa2686e62304c528aa410ce9cdf06b2ed834f", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/team/scenario/episode.yaml": "736a8cc6a7ba18c175fccdddde1f10a1e3440d5bd0bf80594ad5e3abaf05b623", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/team/scenario/notes.md": "2c67451929a289e453a5000b7db263e9e40add97d7ad9a1009bafbe2f0b9e972", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/team/scenario/record.json": "cc5828513fe66db32dd7ddc327a87cb6fd53a463f264a178176a512eea4a9069", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/team/scenario/source.md": "4f9a0b319ba8d16939b017626015676e186c48f234ba7bf764f9c2d967ff6687", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/team/task.json": "85843daa82d273a48a8558a3c67c7a8a0de75dbf48371990de93a675aa3a498c", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/team/task.json": "88ebbe15ced4016bcc944502a566f587928dba4c32c9d11589c3932e628d3583", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/instruction.md": "1c7097785f859926cad84fd7f6296414477194ded624aef9ba74c6c384765486", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/task.toml": "bdea0f60288571290dfc993c6921a29651421e2dcdcc72410575c819acfae8c5", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/task.toml": "6741914c5ef35d242e6d367ea5d549fcea054924854d83b2eb51b7f1e98e0826", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/tests/expected.json": "ed920c325eb5c0f172a5a8864f32350e49709ee4197a422a45e53b10f60a8cc9", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/tests/scenario/episode.yaml": "736a8cc6a7ba18c175fccdddde1f10a1e3440d5bd0bf80594ad5e3abaf05b623", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/tests/scenario/notes.md": "2c67451929a289e453a5000b7db263e9e40add97d7ad9a1009bafbe2f0b9e972", "tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/tests/scenario/record.json": "cc5828513fe66db32dd7ddc327a87cb6fd53a463f264a178176a512eea4a9069", @@ -4272,31 +4276,31 @@ "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/docker-compose.yaml": "223440e5011556dfb4d384ae6c955d43c97266253220f35fa2b4688664534154", - "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/team/scenario/episode.yaml": "405bd8467ddb4faa1dc847326cdc73a92376fbf8afb663e56d6ceecefafc7463", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/team/scenario/notes.md": "f3ce1ed33d2c7b56714278ea12ddfa6d267c44e8e2fee5af605d0cc141664f35", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/team/scenario/record.json": "efc6bd8b76eef8dbe63fcd57ef6b8d1cd0f7e870fadda2b39187457b081a5353", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/team/scenario/source.md": "05e7231f40bbfe7505d92bea8176e6cd63263495e15264ec5149554bffbb4d64", - "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/team/task.json": "ad5a1687f440a31e2da0f83213de458da9bedb1981f31f0e3c72f909ad98a86a", + "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/team/task.json": "9badab325615fb9887feddbd38fa9bddbc9bb43853c9665e73901a25694312e9", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/instruction.md": "e023987ec9c1ee50a5f0b830f0b0ce9a192460966e6f4f14f5008ced4de7e5ea", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/solution/policy.json": "a48b5419516092fe20f4b4e5137d2607b2588da2f2949a07134c5e66d0f63ce2", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/task.toml": "1d9bea21a9b46fc63ba6452d93fda298b71cc51ab7636c01852c7308a4ab1d80", + "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/task.toml": "6b0b09c846abcbfa81845598c28d7755aa94b636e94e7d042543606a483f17d4", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/tests/expected.json": "590088890bd494f790f6486a50c2a5438371f24987a84a53acbaa1b9d72b9c75", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/tests/scenario/episode.yaml": "405bd8467ddb4faa1dc847326cdc73a92376fbf8afb663e56d6ceecefafc7463", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/tests/scenario/notes.md": "f3ce1ed33d2c7b56714278ea12ddfa6d267c44e8e2fee5af605d0cc141664f35", "tasks/ci-sharing-h2-l-photo-meeting-solo-s0/tests/scenario/record.json": "efc6bd8b76eef8dbe63fcd57ef6b8d1cd0f7e870fadda2b39187457b081a5353", @@ -4315,31 +4319,31 @@ "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/docker-compose.yaml": "683b0d86bcfc05d56bdb755358b48c024f259d5790b2fc7ad169c077b13512b9", - "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/team/scenario/episode.yaml": "405bd8467ddb4faa1dc847326cdc73a92376fbf8afb663e56d6ceecefafc7463", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/team/scenario/notes.md": "f3ce1ed33d2c7b56714278ea12ddfa6d267c44e8e2fee5af605d0cc141664f35", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/team/scenario/record.json": "efc6bd8b76eef8dbe63fcd57ef6b8d1cd0f7e870fadda2b39187457b081a5353", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/team/scenario/source.md": "05e7231f40bbfe7505d92bea8176e6cd63263495e15264ec5149554bffbb4d64", - "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/team/task.json": "4f15a24b5538a6504f392be2f0d605fde174d732c18253519162d199c01539f7", + "tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/team/task.json": "9f2b28da4a7dd91b4676933e0ec1842f98d58c5d17b6f536e7db230c386adde1", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/instruction.md": "bc6e1d468e27875ac48aebddd3446f88b0d0513f9a9fa9625c28c1092b51cdcf", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/solution/policy.json": "a48b5419516092fe20f4b4e5137d2607b2588da2f2949a07134c5e66d0f63ce2", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-l-photo-meeting-test-s0/task.toml": "d8616ed4137639b7df2d2a6e54fe83881d304086ebe5ccb767958e62ed913ac1", + "tasks/ci-sharing-h2-l-photo-meeting-test-s0/task.toml": "f264fb09a928e237940dfb701bbbd3f03d7d49bbd1c46b6b6837f80d534de110", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/tests/expected.json": "b53dcb91981805f1d20c0a3bf7c870a88770555e315402f833bd20bee336e357", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-l-photo-meeting-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-l-photo-meeting-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-l-photo-meeting-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-l-photo-meeting-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/tests/scenario/episode.yaml": "405bd8467ddb4faa1dc847326cdc73a92376fbf8afb663e56d6ceecefafc7463", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/tests/scenario/notes.md": "f3ce1ed33d2c7b56714278ea12ddfa6d267c44e8e2fee5af605d0cc141664f35", "tasks/ci-sharing-h2-l-photo-meeting-test-s0/tests/scenario/record.json": "efc6bd8b76eef8dbe63fcd57ef6b8d1cd0f7e870fadda2b39187457b081a5353", @@ -4358,31 +4362,31 @@ "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/docker-compose.yaml": "1521ebaf3cf6fd288c3edc62947eeb33ccf43e180565cc8f24770ff9208e860b", - "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/team/scenario/episode.yaml": "405bd8467ddb4faa1dc847326cdc73a92376fbf8afb663e56d6ceecefafc7463", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/team/scenario/notes.md": "f3ce1ed33d2c7b56714278ea12ddfa6d267c44e8e2fee5af605d0cc141664f35", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/team/scenario/record.json": "efc6bd8b76eef8dbe63fcd57ef6b8d1cd0f7e870fadda2b39187457b081a5353", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/team/scenario/source.md": "05e7231f40bbfe7505d92bea8176e6cd63263495e15264ec5149554bffbb4d64", - "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/team/task.json": "a00cb95a8b1b80766f1648a47573bb2c12429f1780cb5895f2c25afd16d5b537", + "tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/team/task.json": "53b0f4b90bd465b52ec1e89e5cc3f42139096ab102de6be7354b4bffd00743fc", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/instruction.md": "bc6e1d468e27875ac48aebddd3446f88b0d0513f9a9fa9625c28c1092b51cdcf", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/solution/policy.json": "a48b5419516092fe20f4b4e5137d2607b2588da2f2949a07134c5e66d0f63ce2", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-l-photo-meeting-test-s1/task.toml": "b0a066b8e0b802d4e9612dce8fc0cb56f40ea358a76fbb01efb4664c49963cc1", + "tasks/ci-sharing-h2-l-photo-meeting-test-s1/task.toml": "5d7a18edba9764c7cd49a6a8a6885c67f27aa75e3d57d510ffb877c96d631b05", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/tests/expected.json": "13024c86c99562cb03ab2044f3cb0d2504ca6dfed1e2de273558a6701f0fcd23", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-l-photo-meeting-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-l-photo-meeting-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-l-photo-meeting-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-l-photo-meeting-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/tests/scenario/episode.yaml": "405bd8467ddb4faa1dc847326cdc73a92376fbf8afb663e56d6ceecefafc7463", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/tests/scenario/notes.md": "f3ce1ed33d2c7b56714278ea12ddfa6d267c44e8e2fee5af605d0cc141664f35", "tasks/ci-sharing-h2-l-photo-meeting-test-s1/tests/scenario/record.json": "efc6bd8b76eef8dbe63fcd57ef6b8d1cd0f7e870fadda2b39187457b081a5353", @@ -4401,31 +4405,31 @@ "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/docker-compose.yaml": "59c6c82fa9b0273e830983ca713545e7ef0eca7feac40051dc8b7c8bba24752d", - "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/team/scenario/episode.yaml": "405bd8467ddb4faa1dc847326cdc73a92376fbf8afb663e56d6ceecefafc7463", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/team/scenario/notes.md": "f3ce1ed33d2c7b56714278ea12ddfa6d267c44e8e2fee5af605d0cc141664f35", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/team/scenario/record.json": "efc6bd8b76eef8dbe63fcd57ef6b8d1cd0f7e870fadda2b39187457b081a5353", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/team/scenario/source.md": "05e7231f40bbfe7505d92bea8176e6cd63263495e15264ec5149554bffbb4d64", - "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/team/task.json": "912e98e83b937ea446aa3e4ae0d8fa3aa06bf7c2b8db91bcac4d642265b869fe", + "tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/team/task.json": "2ff64c6ec84e3bfd70ba187bb7399436226ea663f3e6c5dcc7e006299b8624c2", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/instruction.md": "bc6e1d468e27875ac48aebddd3446f88b0d0513f9a9fa9625c28c1092b51cdcf", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/solution/policy.json": "a48b5419516092fe20f4b4e5137d2607b2588da2f2949a07134c5e66d0f63ce2", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-l-photo-meeting-test-s2/task.toml": "8f58d35f378513e6db6c96ef4684851553a958e74c87db990feab0fbc4c2d7fc", + "tasks/ci-sharing-h2-l-photo-meeting-test-s2/task.toml": "dc08a90ecec2b1d14770daa7196c03ea8c150b43c7a5bbbdea768e165a396654", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/tests/expected.json": "df928ff956f17adcbd8dae513fbc4575eb34c3dcb3bc38a5daff3561e03f86a8", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-l-photo-meeting-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-l-photo-meeting-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-l-photo-meeting-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-l-photo-meeting-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/tests/scenario/episode.yaml": "405bd8467ddb4faa1dc847326cdc73a92376fbf8afb663e56d6ceecefafc7463", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/tests/scenario/notes.md": "f3ce1ed33d2c7b56714278ea12ddfa6d267c44e8e2fee5af605d0cc141664f35", "tasks/ci-sharing-h2-l-photo-meeting-test-s2/tests/scenario/record.json": "efc6bd8b76eef8dbe63fcd57ef6b8d1cd0f7e870fadda2b39187457b081a5353", @@ -4444,32 +4448,32 @@ "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/docker-compose.yaml": "d59709de897804487f4c1f88395f1f4ab7207f8f27265f9cb920200663f1ef86", - "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/team/scenario/LICENSE": "3756757f3b42032af5e887a06886b09169c417cbf8038df7e5c022e43a3df47b", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/team/scenario/episode.yaml": "1ea22f364144821c8e3f7291f99cf6943fac837022a260a9e6cda71720281c6f", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/team/scenario/notes.md": "0fbb321127ce500a33328a3f2055368f7daeab7e5f742bf8d985375014efa70b", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/team/scenario/record.json": "c56452622c74efc197fe6c5972e9d1f1fa78d52d68de35deaba98e9b2927fa94", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/team/scenario/source.md": "4633e8ed966ca8b75ebc0b28ecf28e628d0c3fee78e3e4a88189eec77497d24c", - "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/team/task.json": "ca49398a51d6f8cd9fecb91b9d3a24667177a3438c6e056c65707e4d655d0877", + "tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/team/task.json": "ca912539e656c7b168a971cd3aa6c929c59c78f6cb51385fac523aa0f54114cf", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/instruction.md": "b7017432884069357c34e931fe0a6169001de927869a31513ae620b8b94574ba", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/solution/policy.json": "471de911a09437a968853275f0d611d733df33e0469f6943045cd28734168bf5", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-l-retained-rock-solo-s0/task.toml": "dc0a757778b0696d870f4cb17e82e6018a3cecd2269317c9ad8cdef637365ab5", + "tasks/ci-sharing-h2-l-retained-rock-solo-s0/task.toml": "680da8e9316c451769c731168b81b310d8145e89860b9526a6d1ebde1e9d2e7c", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/tests/expected.json": "5826815fe21204d265ad18aafb391deef587551f3bab6cc7434cec459bc64756", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-l-retained-rock-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-l-retained-rock-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-l-retained-rock-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-l-retained-rock-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/tests/scenario/LICENSE": "3756757f3b42032af5e887a06886b09169c417cbf8038df7e5c022e43a3df47b", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/tests/scenario/episode.yaml": "1ea22f364144821c8e3f7291f99cf6943fac837022a260a9e6cda71720281c6f", "tasks/ci-sharing-h2-l-retained-rock-solo-s0/tests/scenario/notes.md": "0fbb321127ce500a33328a3f2055368f7daeab7e5f742bf8d985375014efa70b", @@ -4489,32 +4493,32 @@ "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/docker-compose.yaml": "21c9628a566df78ee3a938523ef004c15aeb7830e3866f8c254d661b10e23006", - "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/team/scenario/LICENSE": "3756757f3b42032af5e887a06886b09169c417cbf8038df7e5c022e43a3df47b", "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/team/scenario/episode.yaml": "1ea22f364144821c8e3f7291f99cf6943fac837022a260a9e6cda71720281c6f", "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/team/scenario/notes.md": "0fbb321127ce500a33328a3f2055368f7daeab7e5f742bf8d985375014efa70b", "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/team/scenario/record.json": "c56452622c74efc197fe6c5972e9d1f1fa78d52d68de35deaba98e9b2927fa94", "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/team/scenario/source.md": "4633e8ed966ca8b75ebc0b28ecf28e628d0c3fee78e3e4a88189eec77497d24c", - "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/team/task.json": "94e9f0a57d6697fd77fc298ff60f047ebbb2952d42db377bc3635d73fea12023", + "tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/team/task.json": "8317fa20c8d23fedaee09d0cce7c677d5c78964deb33c2aa8f2484c2582acd1a", "tasks/ci-sharing-h2-l-retained-rock-test-s0/instruction.md": "9ed98459b05d3943cb4345b7d689db929536320b4d5cef2c4abefe9cc10d51d1", "tasks/ci-sharing-h2-l-retained-rock-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-l-retained-rock-test-s0/solution/policy.json": "471de911a09437a968853275f0d611d733df33e0469f6943045cd28734168bf5", "tasks/ci-sharing-h2-l-retained-rock-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-l-retained-rock-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-l-retained-rock-test-s0/task.toml": "eba6fe78a4704af703faf619b3939155d15033e3312951a008743761cf3d12de", + "tasks/ci-sharing-h2-l-retained-rock-test-s0/task.toml": "41234040144e4a4b66299905fcf5a303c45b60266c35aa5539f5b4ea4e4751d7", "tasks/ci-sharing-h2-l-retained-rock-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-l-retained-rock-test-s0/tests/expected.json": "0a14c4da8a6c24bcb1a72e29c66d9f747572d0c7ce490692fa0c8cb04491e318", "tasks/ci-sharing-h2-l-retained-rock-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-l-retained-rock-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-l-retained-rock-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-l-retained-rock-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-l-retained-rock-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-l-retained-rock-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-l-retained-rock-test-s0/tests/scenario/LICENSE": "3756757f3b42032af5e887a06886b09169c417cbf8038df7e5c022e43a3df47b", "tasks/ci-sharing-h2-l-retained-rock-test-s0/tests/scenario/episode.yaml": "1ea22f364144821c8e3f7291f99cf6943fac837022a260a9e6cda71720281c6f", "tasks/ci-sharing-h2-l-retained-rock-test-s0/tests/scenario/notes.md": "0fbb321127ce500a33328a3f2055368f7daeab7e5f742bf8d985375014efa70b", @@ -4534,32 +4538,32 @@ "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/docker-compose.yaml": "d5f9c8f773cada41bdfb492423325d5c8e6eed34a5db6d4de48ffbc105cb6408", - "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/team/scenario/LICENSE": "3756757f3b42032af5e887a06886b09169c417cbf8038df7e5c022e43a3df47b", "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/team/scenario/episode.yaml": "1ea22f364144821c8e3f7291f99cf6943fac837022a260a9e6cda71720281c6f", "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/team/scenario/notes.md": "0fbb321127ce500a33328a3f2055368f7daeab7e5f742bf8d985375014efa70b", "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/team/scenario/record.json": "c56452622c74efc197fe6c5972e9d1f1fa78d52d68de35deaba98e9b2927fa94", "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/team/scenario/source.md": "4633e8ed966ca8b75ebc0b28ecf28e628d0c3fee78e3e4a88189eec77497d24c", - "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/team/task.json": "ee192e5ab2a4b828d1b421af11b667a2bb6018cddba657bfa58d9fbbde8f39a2", + "tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/team/task.json": "7e80279f6feb19f9c64c6c193b1d4e0099358ddc73763cc2d03fa1ed853473d9", "tasks/ci-sharing-h2-l-retained-rock-test-s1/instruction.md": "9ed98459b05d3943cb4345b7d689db929536320b4d5cef2c4abefe9cc10d51d1", "tasks/ci-sharing-h2-l-retained-rock-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-l-retained-rock-test-s1/solution/policy.json": "471de911a09437a968853275f0d611d733df33e0469f6943045cd28734168bf5", "tasks/ci-sharing-h2-l-retained-rock-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-l-retained-rock-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-l-retained-rock-test-s1/task.toml": "f73c3c283dd5392cdab27e1b94b2d1f531610a37f72c33298b10a0f1675b0cc3", + "tasks/ci-sharing-h2-l-retained-rock-test-s1/task.toml": "f95b96613d6aac56af5557b475a8af4327f8d3b78484fc8aaaf84767176106ef", "tasks/ci-sharing-h2-l-retained-rock-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-l-retained-rock-test-s1/tests/expected.json": "2943a979e591cdc1492bf254d6c5fa04dd44a7a3d4b792b3ec88fdd45594ba2c", "tasks/ci-sharing-h2-l-retained-rock-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-l-retained-rock-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-l-retained-rock-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-l-retained-rock-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-l-retained-rock-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-l-retained-rock-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-l-retained-rock-test-s1/tests/scenario/LICENSE": "3756757f3b42032af5e887a06886b09169c417cbf8038df7e5c022e43a3df47b", "tasks/ci-sharing-h2-l-retained-rock-test-s1/tests/scenario/episode.yaml": "1ea22f364144821c8e3f7291f99cf6943fac837022a260a9e6cda71720281c6f", "tasks/ci-sharing-h2-l-retained-rock-test-s1/tests/scenario/notes.md": "0fbb321127ce500a33328a3f2055368f7daeab7e5f742bf8d985375014efa70b", @@ -4579,32 +4583,32 @@ "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/docker-compose.yaml": "42bc3fca50748d7ef34a27c64ed6dd82ab7a61583022b4b21886d990a354ff2d", - "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/team/scenario/LICENSE": "3756757f3b42032af5e887a06886b09169c417cbf8038df7e5c022e43a3df47b", "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/team/scenario/episode.yaml": "1ea22f364144821c8e3f7291f99cf6943fac837022a260a9e6cda71720281c6f", "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/team/scenario/notes.md": "0fbb321127ce500a33328a3f2055368f7daeab7e5f742bf8d985375014efa70b", "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/team/scenario/record.json": "c56452622c74efc197fe6c5972e9d1f1fa78d52d68de35deaba98e9b2927fa94", "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/team/scenario/source.md": "4633e8ed966ca8b75ebc0b28ecf28e628d0c3fee78e3e4a88189eec77497d24c", - "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/team/task.json": "81b6f1edd621641b5a9ccdc03ec8b8982d0b0b3c5f663820143f840a3e516e42", + "tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/team/task.json": "4724a1db453f847aca49f01596848b0d63d1859e85dcd534d2ea3116019088a2", "tasks/ci-sharing-h2-l-retained-rock-test-s2/instruction.md": "9ed98459b05d3943cb4345b7d689db929536320b4d5cef2c4abefe9cc10d51d1", "tasks/ci-sharing-h2-l-retained-rock-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-l-retained-rock-test-s2/solution/policy.json": "471de911a09437a968853275f0d611d733df33e0469f6943045cd28734168bf5", "tasks/ci-sharing-h2-l-retained-rock-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-l-retained-rock-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-l-retained-rock-test-s2/task.toml": "a9d147b05e78cf918cf50c94f8b1ff748c5b0e8944da6c0246c2765335946f4c", + "tasks/ci-sharing-h2-l-retained-rock-test-s2/task.toml": "78d39780e98af3e9f596314f9f4ad2403b92283ae2269449c8915815876d5f53", "tasks/ci-sharing-h2-l-retained-rock-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-l-retained-rock-test-s2/tests/expected.json": "c990951d4b16884280364aa062b0900f06a28d45173e27f51f0f1582d7f76205", "tasks/ci-sharing-h2-l-retained-rock-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-l-retained-rock-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-l-retained-rock-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-l-retained-rock-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-l-retained-rock-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-l-retained-rock-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-l-retained-rock-test-s2/tests/scenario/LICENSE": "3756757f3b42032af5e887a06886b09169c417cbf8038df7e5c022e43a3df47b", "tasks/ci-sharing-h2-l-retained-rock-test-s2/tests/scenario/episode.yaml": "1ea22f364144821c8e3f7291f99cf6943fac837022a260a9e6cda71720281c6f", "tasks/ci-sharing-h2-l-retained-rock-test-s2/tests/scenario/notes.md": "0fbb321127ce500a33328a3f2055368f7daeab7e5f742bf8d985375014efa70b", @@ -4624,31 +4628,31 @@ "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/docker-compose.yaml": "f45e6bf246d4f496988b6760a8531a2926d8bdc0d1e95b1eb028d3b1412f57fc", - "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/team/scenario/episode.yaml": "aa9af8ed5d8995b23ca1648ba286f0a2986a2bff65b23ac92b25067b2fec58b1", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/team/scenario/notes.md": "88895226b053d779b174bb8db7f766969c3e19eb33be9c6b753a4202e70cdf31", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/team/scenario/record.json": "735f4a18c6ab768722bb94561993c7b8e1d543bdda7b5d95b3ae6659e81df56e", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/team/scenario/source.md": "baffe70e328dafae60a872b5123584b9d685da917078ef0d6a2a5f673e464ebf", - "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/team/task.json": "a4791af9f01e288fbc90f7a6cd84683f87c7a81eb94b0a52c940a86fd43175e6", + "tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/team/task.json": "42150ebe625db4c4f3d1e83667d62abd6c828fb618293168f6837693b9753fd0", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/instruction.md": "0291fb74224e6d2b8d6190ad62ea6cfcce502fcc756dc97dc43f92372772187e", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/solution/policy.json": "24b0eb0a1481c400719b8fa704a6479406f56de65091c1c3c2e23e3307575262", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-n-lead-investor-solo-s0/task.toml": "85e1328c6992ac5b281aa326f685c1acb3d882941140f816f51f034237caa480", + "tasks/ci-sharing-h2-n-lead-investor-solo-s0/task.toml": "4037152f800971ddbff0f60457a5eae98c684ebe7e984e6f1711a947144b309e", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/tests/expected.json": "7206f387e9cd4a4be7e05aa284d49bc9bd202501cf9c558e77d5e284b9e0758a", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-n-lead-investor-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-n-lead-investor-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-n-lead-investor-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-n-lead-investor-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/tests/scenario/episode.yaml": "aa9af8ed5d8995b23ca1648ba286f0a2986a2bff65b23ac92b25067b2fec58b1", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/tests/scenario/notes.md": "88895226b053d779b174bb8db7f766969c3e19eb33be9c6b753a4202e70cdf31", "tasks/ci-sharing-h2-n-lead-investor-solo-s0/tests/scenario/record.json": "735f4a18c6ab768722bb94561993c7b8e1d543bdda7b5d95b3ae6659e81df56e", @@ -4667,31 +4671,31 @@ "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/docker-compose.yaml": "c00e6b648bda75be48f71fa389f117db0a369a8bc0f5215dec66ab35524f6ed7", - "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/team/scenario/episode.yaml": "aa9af8ed5d8995b23ca1648ba286f0a2986a2bff65b23ac92b25067b2fec58b1", "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/team/scenario/notes.md": "88895226b053d779b174bb8db7f766969c3e19eb33be9c6b753a4202e70cdf31", "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/team/scenario/record.json": "735f4a18c6ab768722bb94561993c7b8e1d543bdda7b5d95b3ae6659e81df56e", "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/team/scenario/source.md": "baffe70e328dafae60a872b5123584b9d685da917078ef0d6a2a5f673e464ebf", - "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/team/task.json": "5679071e09b0bc9f99b3493733038ed6ba860dbea1e6aa570cf66b5607337097", + "tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/team/task.json": "9cdf2b2c1b6ce64deeee431e32a443a98e60d50c40d9580e174a139311da1a65", "tasks/ci-sharing-h2-n-lead-investor-test-s0/instruction.md": "cfcc4c1ac01f10f5991e75d4476fcfe7d7e49920a5a7499d95ef44796d7ee288", "tasks/ci-sharing-h2-n-lead-investor-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-n-lead-investor-test-s0/solution/policy.json": "24b0eb0a1481c400719b8fa704a6479406f56de65091c1c3c2e23e3307575262", "tasks/ci-sharing-h2-n-lead-investor-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-n-lead-investor-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-n-lead-investor-test-s0/task.toml": "32a8ab5488e9ccb83a25bdf183ca25127ab0de29a208d3346ca22507876e9dbf", + "tasks/ci-sharing-h2-n-lead-investor-test-s0/task.toml": "4a492c44894285e2b2504b368405072691863dd7c58965737de0157f0419d1bb", "tasks/ci-sharing-h2-n-lead-investor-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-n-lead-investor-test-s0/tests/expected.json": "dce43fd830d532a4626f292f02ec6aabada56a4a594a34840be6d685e6d4d518", "tasks/ci-sharing-h2-n-lead-investor-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-n-lead-investor-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-n-lead-investor-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-n-lead-investor-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-n-lead-investor-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-n-lead-investor-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-n-lead-investor-test-s0/tests/scenario/episode.yaml": "aa9af8ed5d8995b23ca1648ba286f0a2986a2bff65b23ac92b25067b2fec58b1", "tasks/ci-sharing-h2-n-lead-investor-test-s0/tests/scenario/notes.md": "88895226b053d779b174bb8db7f766969c3e19eb33be9c6b753a4202e70cdf31", "tasks/ci-sharing-h2-n-lead-investor-test-s0/tests/scenario/record.json": "735f4a18c6ab768722bb94561993c7b8e1d543bdda7b5d95b3ae6659e81df56e", @@ -4710,31 +4714,31 @@ "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/docker-compose.yaml": "5ab66c51b76ce92d501168edbca665de24a274046c1fdda33bdc75da0c4a9572", - "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/team/scenario/episode.yaml": "aa9af8ed5d8995b23ca1648ba286f0a2986a2bff65b23ac92b25067b2fec58b1", "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/team/scenario/notes.md": "88895226b053d779b174bb8db7f766969c3e19eb33be9c6b753a4202e70cdf31", "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/team/scenario/record.json": "735f4a18c6ab768722bb94561993c7b8e1d543bdda7b5d95b3ae6659e81df56e", "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/team/scenario/source.md": "baffe70e328dafae60a872b5123584b9d685da917078ef0d6a2a5f673e464ebf", - "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/team/task.json": "faaf6700f53f01154436062514fdaff679ed341c3e27e23f7d1ef6e0759765a4", + "tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/team/task.json": "893fcbdba494812eef058c1f5d2574350c1699a756ff5a69d4b8df9c1d036ceb", "tasks/ci-sharing-h2-n-lead-investor-test-s1/instruction.md": "cfcc4c1ac01f10f5991e75d4476fcfe7d7e49920a5a7499d95ef44796d7ee288", "tasks/ci-sharing-h2-n-lead-investor-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-n-lead-investor-test-s1/solution/policy.json": "24b0eb0a1481c400719b8fa704a6479406f56de65091c1c3c2e23e3307575262", "tasks/ci-sharing-h2-n-lead-investor-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-n-lead-investor-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-n-lead-investor-test-s1/task.toml": "66ae8e43298278072b140cb7cb52b347aadd8f2f47070acbe6f7996bf2ecca36", + "tasks/ci-sharing-h2-n-lead-investor-test-s1/task.toml": "cc6a188afbf0858d4e83b36526e7143663f8d716a3b28ebfa140cc3161b28257", "tasks/ci-sharing-h2-n-lead-investor-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-n-lead-investor-test-s1/tests/expected.json": "c249a97e01f38da0ee08adf056eecbc780864f353c83285fab36706bf328e488", "tasks/ci-sharing-h2-n-lead-investor-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-n-lead-investor-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-n-lead-investor-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-n-lead-investor-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-n-lead-investor-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-n-lead-investor-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-n-lead-investor-test-s1/tests/scenario/episode.yaml": "aa9af8ed5d8995b23ca1648ba286f0a2986a2bff65b23ac92b25067b2fec58b1", "tasks/ci-sharing-h2-n-lead-investor-test-s1/tests/scenario/notes.md": "88895226b053d779b174bb8db7f766969c3e19eb33be9c6b753a4202e70cdf31", "tasks/ci-sharing-h2-n-lead-investor-test-s1/tests/scenario/record.json": "735f4a18c6ab768722bb94561993c7b8e1d543bdda7b5d95b3ae6659e81df56e", @@ -4753,31 +4757,31 @@ "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/docker-compose.yaml": "c67f8717590e4abcbc89778ebc50ed865f842d8f502cbf75d4476242e4cfbebc", - "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/team/scenario/episode.yaml": "aa9af8ed5d8995b23ca1648ba286f0a2986a2bff65b23ac92b25067b2fec58b1", "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/team/scenario/notes.md": "88895226b053d779b174bb8db7f766969c3e19eb33be9c6b753a4202e70cdf31", "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/team/scenario/record.json": "735f4a18c6ab768722bb94561993c7b8e1d543bdda7b5d95b3ae6659e81df56e", "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/team/scenario/source.md": "baffe70e328dafae60a872b5123584b9d685da917078ef0d6a2a5f673e464ebf", - "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/team/task.json": "c548319d72dcb566d7b162a5bf58f33563e85defddd0cc93db628f2100f03b8c", + "tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/team/task.json": "dd37922292bb06104b0dc2fe57c6be07fdf0b4997d3fafc29ff378d24e5c3ba2", "tasks/ci-sharing-h2-n-lead-investor-test-s2/instruction.md": "cfcc4c1ac01f10f5991e75d4476fcfe7d7e49920a5a7499d95ef44796d7ee288", "tasks/ci-sharing-h2-n-lead-investor-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-n-lead-investor-test-s2/solution/policy.json": "24b0eb0a1481c400719b8fa704a6479406f56de65091c1c3c2e23e3307575262", "tasks/ci-sharing-h2-n-lead-investor-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-n-lead-investor-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-n-lead-investor-test-s2/task.toml": "ac997071f9ac41db7d81192b3dfd676f12a1f0544b28804eb63f278ee9bd8ad7", + "tasks/ci-sharing-h2-n-lead-investor-test-s2/task.toml": "b7595836a1d414c0dfa153b20718786e743515bba432c7c5acf5bbfc2f808fc6", "tasks/ci-sharing-h2-n-lead-investor-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-n-lead-investor-test-s2/tests/expected.json": "3f5879f744bb6ef866ac344dd6bebba3b288f5db5ddd3b9d616ecbaf0b5f654a", "tasks/ci-sharing-h2-n-lead-investor-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-n-lead-investor-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-n-lead-investor-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-n-lead-investor-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-n-lead-investor-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-n-lead-investor-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-n-lead-investor-test-s2/tests/scenario/episode.yaml": "aa9af8ed5d8995b23ca1648ba286f0a2986a2bff65b23ac92b25067b2fec58b1", "tasks/ci-sharing-h2-n-lead-investor-test-s2/tests/scenario/notes.md": "88895226b053d779b174bb8db7f766969c3e19eb33be9c6b753a4202e70cdf31", "tasks/ci-sharing-h2-n-lead-investor-test-s2/tests/scenario/record.json": "735f4a18c6ab768722bb94561993c7b8e1d543bdda7b5d95b3ae6659e81df56e", @@ -4796,31 +4800,31 @@ "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/docker-compose.yaml": "1d171b3dc367d5ff521fb6ee13dcd602d4d3da5a48dde131ae11fbf73e380d47", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/team/scenario/episode.yaml": "9e5eb15209a1eb175546caacc39744ac3e7162b14f0b0877a716256633847c4c", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/team/scenario/notes.md": "04980d008b43a8672c39919facac8bec74acbf1235131b9ebcd8688e64123b03", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/team/scenario/record.json": "8e8d99faba5d2edb1c88af126792c111be73abab0e87886c53e0a97002ae6eba", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/team/scenario/source.md": "e838a5ba4d3508d74fc7ae93103871b0f946bd483cae87804ba0491df5d5c0d5", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/team/task.json": "8ab4427f7dfd0a43bf586adade70bbb941392c3607f64eba11cac7a803ddebb1", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/team/task.json": "ee24211633e0ab0b5b270371dd832b11e0386a852bcaff9ecc05faeeec6d2313", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/instruction.md": "7c4a1b8b87bdc8751f952a4ea4498e12e308909b1a6f62b0db719ad02dda7162", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/solution/policy.json": "55914257ef25e9e9a14e50082c890b98ac4e790766f3665529d6bf4281221e52", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/task.toml": "8e73d9bed8b1646dfd5121082bd3fbc4af6bc4cc6a67aeb44c11d1e14141f7c8", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/task.toml": "b6fa2e763e7577b9380836980d9533491f3fd7d94c85ad2911e5232089a4b53b", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/tests/expected.json": "0e89d7fed5d95058dd5412329107b5b9356c7fce314bfcdb69c61a34ab6c1f08", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/tests/scenario/episode.yaml": "9e5eb15209a1eb175546caacc39744ac3e7162b14f0b0877a716256633847c4c", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/tests/scenario/notes.md": "04980d008b43a8672c39919facac8bec74acbf1235131b9ebcd8688e64123b03", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/tests/scenario/record.json": "8e8d99faba5d2edb1c88af126792c111be73abab0e87886c53e0a97002ae6eba", @@ -4839,31 +4843,31 @@ "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/docker-compose.yaml": "a49c59ed09536ed6b4a8f9c70e9c308b0b7ca6cc058266d5da38fff5bdfdd5b3", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/team/scenario/episode.yaml": "9e5eb15209a1eb175546caacc39744ac3e7162b14f0b0877a716256633847c4c", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/team/scenario/notes.md": "04980d008b43a8672c39919facac8bec74acbf1235131b9ebcd8688e64123b03", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/team/scenario/record.json": "8e8d99faba5d2edb1c88af126792c111be73abab0e87886c53e0a97002ae6eba", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/team/scenario/source.md": "e838a5ba4d3508d74fc7ae93103871b0f946bd483cae87804ba0491df5d5c0d5", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/team/task.json": "e3a9a9fab4337fe43181e4b41aa24b24522ed024644cc50a85a52968ec2efba4", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/team/task.json": "345791c25c4c9384ddebdc488c650d0da5b4e8364785d35b0327c153896f4053", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/instruction.md": "2f899415f775b5369534753311a821c28d23ca3a4ef587cdba4afddcc132ff2f", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/solution/policy.json": "55914257ef25e9e9a14e50082c890b98ac4e790766f3665529d6bf4281221e52", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/task.toml": "d0561f147cdc3c30d8bc05b604588d95644ebfbd72c1ae9d4a08df7e307b29c5", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/task.toml": "90dd8b2b45de85b864194226f6669d2bb0e97315c5cadbe0ca7323517d151d52", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/tests/expected.json": "d17acd6d4a14fce85728d9e711c87620f6240719a8415f467e0cd45b6a4523e5", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/tests/scenario/episode.yaml": "9e5eb15209a1eb175546caacc39744ac3e7162b14f0b0877a716256633847c4c", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/tests/scenario/notes.md": "04980d008b43a8672c39919facac8bec74acbf1235131b9ebcd8688e64123b03", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/tests/scenario/record.json": "8e8d99faba5d2edb1c88af126792c111be73abab0e87886c53e0a97002ae6eba", @@ -4882,31 +4886,31 @@ "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/docker-compose.yaml": "403dea2de0d8ff2700049eaf5ffda2982be9e03a972a10cd02fee322805f9541", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/team/scenario/episode.yaml": "9e5eb15209a1eb175546caacc39744ac3e7162b14f0b0877a716256633847c4c", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/team/scenario/notes.md": "04980d008b43a8672c39919facac8bec74acbf1235131b9ebcd8688e64123b03", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/team/scenario/record.json": "8e8d99faba5d2edb1c88af126792c111be73abab0e87886c53e0a97002ae6eba", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/team/scenario/source.md": "e838a5ba4d3508d74fc7ae93103871b0f946bd483cae87804ba0491df5d5c0d5", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/team/task.json": "5fe05835cbd2f98748e1fb7456142704e89cb6531861be9f559b7f989972e8ca", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/team/task.json": "6e3895858f6d6feb6415f4001629aeb01faec235bb05b38e55d233c500fd7974", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/instruction.md": "2f899415f775b5369534753311a821c28d23ca3a4ef587cdba4afddcc132ff2f", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/solution/policy.json": "55914257ef25e9e9a14e50082c890b98ac4e790766f3665529d6bf4281221e52", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/task.toml": "1f20b07fc57e89df79ec9e0c28425257ecc6120fe5b9108d79d246b1ea67b8ab", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/task.toml": "00b9bc1b5c125f1fab69e12c9ea0f08949b990a66ce84fb92d04f1dfc8c02779", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/tests/expected.json": "12197a23122b00803c51f0d709defb93c423d86f27e7023f79f1fb8039058b64", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/tests/scenario/episode.yaml": "9e5eb15209a1eb175546caacc39744ac3e7162b14f0b0877a716256633847c4c", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/tests/scenario/notes.md": "04980d008b43a8672c39919facac8bec74acbf1235131b9ebcd8688e64123b03", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/tests/scenario/record.json": "8e8d99faba5d2edb1c88af126792c111be73abab0e87886c53e0a97002ae6eba", @@ -4925,31 +4929,31 @@ "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/docker-compose.yaml": "96e19e98c06752ffe962919e7a2b45ab8dac7e7edf7c78a775714eccb81d4ce8", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/team/scenario/episode.yaml": "9e5eb15209a1eb175546caacc39744ac3e7162b14f0b0877a716256633847c4c", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/team/scenario/notes.md": "04980d008b43a8672c39919facac8bec74acbf1235131b9ebcd8688e64123b03", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/team/scenario/record.json": "8e8d99faba5d2edb1c88af126792c111be73abab0e87886c53e0a97002ae6eba", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/team/scenario/source.md": "e838a5ba4d3508d74fc7ae93103871b0f946bd483cae87804ba0491df5d5c0d5", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/team/task.json": "608282c797c744fbbf498956c45fa54e58e8a3d5ce8b6dccbcddbe00d5551f11", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/team/task.json": "e0bda077bdb399415ff2b257b2598abe57923ad804457b1d529bebdcf94670f8", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/instruction.md": "2f899415f775b5369534753311a821c28d23ca3a4ef587cdba4afddcc132ff2f", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/solution/policy.json": "55914257ef25e9e9a14e50082c890b98ac4e790766f3665529d6bf4281221e52", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/task.toml": "a86036198de2d9249f1c06467cb04d8688a24d098718b98b2c15710ebaff4e1f", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/task.toml": "27027f021324db9ea58f39b73f198526c4dfc5489b95ee24e9e577c156ae48d3", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/tests/expected.json": "f781ada155112010e7360a8c1fc2c3754f5fe333763a78e80e209732e985f981", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/tests/scenario/episode.yaml": "9e5eb15209a1eb175546caacc39744ac3e7162b14f0b0877a716256633847c4c", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/tests/scenario/notes.md": "04980d008b43a8672c39919facac8bec74acbf1235131b9ebcd8688e64123b03", "tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/tests/scenario/record.json": "8e8d99faba5d2edb1c88af126792c111be73abab0e87886c53e0a97002ae6eba", @@ -4968,31 +4972,31 @@ "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/docker-compose.yaml": "922732270c0c8fc9ff22135fced8a83c552f661a251163e1927c8383c8dcaf34", - "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/team/scenario/episode.yaml": "23561a9156d196ff8f3a0bd06d09fee6326a8ef21b76f821d6bb06e79a815fcc", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/team/scenario/notes.md": "ffd49806c16a1a277e5412887f551198161cb316fc13114b516208cb656d88bb", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/team/scenario/record.json": "663f5e4ae7c2e28a71e41d57ea340e476e54d8ccd5cecdb34b4710f97c1be6ce", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/team/scenario/source.md": "4171714ca748247d73f444045db7cbb444619e31d9dad845b49c00c8e26f6be6", - "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/team/task.json": "b2dfef32569eb22f55b5ac91ca42b63bc5a3754d196d76cb5fd518e93e5b9500", + "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/team/task.json": "7733727e1e99f2259ea9abe987217d8377fe50cbfccdb62ad0422abd6b3f938e", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/instruction.md": "3dfaf58a9229d09408375b0fb92e4a9bf7bb19d79bf02f1632fe65169f7ced5f", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/solution/policy.json": "136f83e2dbe4bc0a8bcd42b377176a931eb0703b4dd357d3a2bb2dcdce18772d", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/task.toml": "d74f0ee869494cac1bdcdf8650d5d6519bc659763c7df14500b470a6258b7e0b", + "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/task.toml": "ec5a2ab3cbf8833cab64a24b34cc393a4c77b497890946a7398e160b77d93730", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/tests/expected.json": "e9b340dbded3e8083d019b512523433c0da065b698d6fb0b2a1d1342467351bb", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/tests/scenario/episode.yaml": "23561a9156d196ff8f3a0bd06d09fee6326a8ef21b76f821d6bb06e79a815fcc", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/tests/scenario/notes.md": "ffd49806c16a1a277e5412887f551198161cb316fc13114b516208cb656d88bb", "tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/tests/scenario/record.json": "663f5e4ae7c2e28a71e41d57ea340e476e54d8ccd5cecdb34b4710f97c1be6ce", @@ -5011,31 +5015,31 @@ "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/docker-compose.yaml": "6bee4b4299ffbfdc15583879133d1227bd98ac3b74fff91db6d38449fb43e127", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/team/scenario/episode.yaml": "23561a9156d196ff8f3a0bd06d09fee6326a8ef21b76f821d6bb06e79a815fcc", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/team/scenario/notes.md": "ffd49806c16a1a277e5412887f551198161cb316fc13114b516208cb656d88bb", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/team/scenario/record.json": "663f5e4ae7c2e28a71e41d57ea340e476e54d8ccd5cecdb34b4710f97c1be6ce", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/team/scenario/source.md": "4171714ca748247d73f444045db7cbb444619e31d9dad845b49c00c8e26f6be6", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/team/task.json": "eda4a22a5cf6d33740b133025d17cbfd9c939d65014fce6143cb72eaa4472182", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/team/task.json": "d690f75e57abdc43e55e9df5f63456e1717ccfcf3bef8bdf65c57bbe8a944c15", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/instruction.md": "c2a097eb0af3397e2d1b08a684c22c761cba42d70c0006c6ee6d41ba6da9e8ce", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/solution/policy.json": "136f83e2dbe4bc0a8bcd42b377176a931eb0703b4dd357d3a2bb2dcdce18772d", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/task.toml": "21d82b59cec4f8d1e80d702d101a375d1881df9ac13952c706f10d46a1d7f039", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/task.toml": "909355019163708baa3500d41c955bdc66677dc1cae45bf3f81914b5d06b9d07", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/tests/expected.json": "e121eafebca0a60c7afc95e7835823bf07b27d9830c0d91217867b3b7385697d", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/tests/scenario/episode.yaml": "23561a9156d196ff8f3a0bd06d09fee6326a8ef21b76f821d6bb06e79a815fcc", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/tests/scenario/notes.md": "ffd49806c16a1a277e5412887f551198161cb316fc13114b516208cb656d88bb", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/tests/scenario/record.json": "663f5e4ae7c2e28a71e41d57ea340e476e54d8ccd5cecdb34b4710f97c1be6ce", @@ -5054,31 +5058,31 @@ "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/docker-compose.yaml": "efc536263c049548e9d524847f8d58e17de74adbc432ff485f6dbc1465ef8def", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/team/scenario/episode.yaml": "23561a9156d196ff8f3a0bd06d09fee6326a8ef21b76f821d6bb06e79a815fcc", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/team/scenario/notes.md": "ffd49806c16a1a277e5412887f551198161cb316fc13114b516208cb656d88bb", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/team/scenario/record.json": "663f5e4ae7c2e28a71e41d57ea340e476e54d8ccd5cecdb34b4710f97c1be6ce", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/team/scenario/source.md": "4171714ca748247d73f444045db7cbb444619e31d9dad845b49c00c8e26f6be6", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/team/task.json": "2c193abb6adb55b61eafe60b5f60a5951f4178c12f4d03573031e061c3cf173b", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/team/task.json": "fb7dd24b227767e23852cbfda92e2deadc1544fbf5bc20cb08a74beafd7e9ae0", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/instruction.md": "c2a097eb0af3397e2d1b08a684c22c761cba42d70c0006c6ee6d41ba6da9e8ce", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/solution/policy.json": "136f83e2dbe4bc0a8bcd42b377176a931eb0703b4dd357d3a2bb2dcdce18772d", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/task.toml": "75824e73e79b744f0cb4a0072c80b20e6b754407cf64a4229350c84443b56ee8", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/task.toml": "3dce85218847490447011971fccc0b239291fd9697e899ad50f493a8b420d295", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/tests/expected.json": "dab8ce387947dfe8d6eff93a1c53badb8cfc5579bb39df8c9c03a16273f71bc3", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/tests/scenario/episode.yaml": "23561a9156d196ff8f3a0bd06d09fee6326a8ef21b76f821d6bb06e79a815fcc", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/tests/scenario/notes.md": "ffd49806c16a1a277e5412887f551198161cb316fc13114b516208cb656d88bb", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/tests/scenario/record.json": "663f5e4ae7c2e28a71e41d57ea340e476e54d8ccd5cecdb34b4710f97c1be6ce", @@ -5097,31 +5101,31 @@ "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/docker-compose.yaml": "b54ae093fa82a2cd804aad6e48d6e8b4af76482b9f3b6384fbccaf61ca70b2f3", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/team/scenario/episode.yaml": "23561a9156d196ff8f3a0bd06d09fee6326a8ef21b76f821d6bb06e79a815fcc", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/team/scenario/notes.md": "ffd49806c16a1a277e5412887f551198161cb316fc13114b516208cb656d88bb", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/team/scenario/record.json": "663f5e4ae7c2e28a71e41d57ea340e476e54d8ccd5cecdb34b4710f97c1be6ce", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/team/scenario/source.md": "4171714ca748247d73f444045db7cbb444619e31d9dad845b49c00c8e26f6be6", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/team/task.json": "c454ded24163ee6bd9a61d7fd3a3d89736ae707af9faf13f07d7276b4d2a9534", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/team/task.json": "3e4d472ade77ccd7a9e7dfca5b394055d96b78d9dcfde88b5e30d4c160ded9e6", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/instruction.md": "c2a097eb0af3397e2d1b08a684c22c761cba42d70c0006c6ee6d41ba6da9e8ce", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/solution/policy.json": "136f83e2dbe4bc0a8bcd42b377176a931eb0703b4dd357d3a2bb2dcdce18772d", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/task.toml": "7d90fa4e737f905b0a48c0fba6057946f4e571b7264be779e2758b4af03482d9", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/task.toml": "9eafab98f394e7e494d229b076dcce4c393a70cddc780f560e39e230353bf285", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/tests/expected.json": "c44403a6112161ce7f3b06fb8acf7805ffe70395d5b89ab48a925229ac84a9ab", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/tests/scenario/episode.yaml": "23561a9156d196ff8f3a0bd06d09fee6326a8ef21b76f821d6bb06e79a815fcc", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/tests/scenario/notes.md": "ffd49806c16a1a277e5412887f551198161cb316fc13114b516208cb656d88bb", "tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/tests/scenario/record.json": "663f5e4ae7c2e28a71e41d57ea340e476e54d8ccd5cecdb34b4710f97c1be6ce", @@ -5140,31 +5144,31 @@ "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/docker-compose.yaml": "fc7dbb4db6f410376a1931ed5eaad217f0c8070f5123193d7cd2b4c98a7f9f21", - "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/team/scenario/episode.yaml": "52ca72727aa1937390d3b0686443a5ca2ef74820ba620b1e5ea0fad80971859d", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/team/scenario/notes.md": "f19bdd9a154771bf7de8387311b3df0d69020b6d921437e7d85157c47a9188e1", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/team/scenario/record.json": "7ad0016efe0e4dac2abced1f0450d90e0f0c38970abb31c8f69e710f4bc922e4", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/team/scenario/source.md": "00e1af7d7db9397f6cbd5146fb1b30618abd20101b097d938e4012edce82a761", - "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/team/task.json": "d420b7e9e3293662f278d3f3d52b01da8eaf9f578d1275eca59f392b6cd8ca41", + "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/team/task.json": "9040011f4cb499cf915713c6ddd7a44e3216df7eb83474b0b79bb66dd53b85d7", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/instruction.md": "b97bd02163998451b335f5a09ee68dd7d0c446aba1e607c4ef56e479222a094e", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/solution/policy.json": "62268c58729481cd02e159a3adf67badd0eef36d68be66228a588b7ffaf918c8", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/task.toml": "069b3f8cb16c75970432ea050242a4f8dc54a170693862ed14c0787d6e68772b", + "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/task.toml": "96cea99ab5a41074f3189a14c20223fe4d404e87d669b94b79f8d4b899f5acfc", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/tests/expected.json": "958e23ed93b30f32991db83d0c7cca12dbef40e71843a47d9290d887ceda340a", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/tests/scenario/episode.yaml": "52ca72727aa1937390d3b0686443a5ca2ef74820ba620b1e5ea0fad80971859d", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/tests/scenario/notes.md": "f19bdd9a154771bf7de8387311b3df0d69020b6d921437e7d85157c47a9188e1", "tasks/ci-sharing-h2-x-negotiation-site-solo-s0/tests/scenario/record.json": "7ad0016efe0e4dac2abced1f0450d90e0f0c38970abb31c8f69e710f4bc922e4", @@ -5183,31 +5187,31 @@ "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/docker-compose.yaml": "8a24e6ca9a224325ba7dcfcfef80c732546aa4382fa47b44253a6faf9901bc56", - "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/team/scenario/episode.yaml": "52ca72727aa1937390d3b0686443a5ca2ef74820ba620b1e5ea0fad80971859d", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/team/scenario/notes.md": "f19bdd9a154771bf7de8387311b3df0d69020b6d921437e7d85157c47a9188e1", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/team/scenario/record.json": "7ad0016efe0e4dac2abced1f0450d90e0f0c38970abb31c8f69e710f4bc922e4", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/team/scenario/source.md": "00e1af7d7db9397f6cbd5146fb1b30618abd20101b097d938e4012edce82a761", - "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/team/task.json": "2af7511ac71c8f42cfb8a7e19958415c9658fec6b4ff615764fb853f78b2efd4", + "tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/team/task.json": "90bb5a00adf5a9c69fd76bb9972507ad566795331274a06943b64f74c54b6541", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/instruction.md": "53d05baa22c2feda4fbddf1d07a6c820481351a366d2207da08b1586c7691897", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/solution/policy.json": "62268c58729481cd02e159a3adf67badd0eef36d68be66228a588b7ffaf918c8", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-x-negotiation-site-test-s0/task.toml": "005fe1f8f5b9a30f984c48e8adc317b036d52d0afa4cfa7642848393f1aa7a49", + "tasks/ci-sharing-h2-x-negotiation-site-test-s0/task.toml": "c028c2fdf6dc5d8b54b7c444501f14b402d9db88fc53592851b782403e6b6b3f", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/tests/expected.json": "8121e64d2c32b7d0a03bb9ddc979beed7d5fbf2359c6cfc3b3c441f0f28c1d98", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-x-negotiation-site-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-x-negotiation-site-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-x-negotiation-site-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-x-negotiation-site-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/tests/scenario/episode.yaml": "52ca72727aa1937390d3b0686443a5ca2ef74820ba620b1e5ea0fad80971859d", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/tests/scenario/notes.md": "f19bdd9a154771bf7de8387311b3df0d69020b6d921437e7d85157c47a9188e1", "tasks/ci-sharing-h2-x-negotiation-site-test-s0/tests/scenario/record.json": "7ad0016efe0e4dac2abced1f0450d90e0f0c38970abb31c8f69e710f4bc922e4", @@ -5226,31 +5230,31 @@ "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/docker-compose.yaml": "bd8970a7d8dbed645606e9d3b5a08d80e9584140e9a8f0519b7b0f751775a20e", - "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/team/scenario/episode.yaml": "52ca72727aa1937390d3b0686443a5ca2ef74820ba620b1e5ea0fad80971859d", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/team/scenario/notes.md": "f19bdd9a154771bf7de8387311b3df0d69020b6d921437e7d85157c47a9188e1", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/team/scenario/record.json": "7ad0016efe0e4dac2abced1f0450d90e0f0c38970abb31c8f69e710f4bc922e4", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/team/scenario/source.md": "00e1af7d7db9397f6cbd5146fb1b30618abd20101b097d938e4012edce82a761", - "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/team/task.json": "70ab04a6769a699098d1698546ed1d29e8b5202217e5e624126c54edcd1209fb", + "tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/team/task.json": "162101db5e1a5a47e49dd240f6e78d17f031cc40ba680cc8117b66c8540c5c5b", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/instruction.md": "53d05baa22c2feda4fbddf1d07a6c820481351a366d2207da08b1586c7691897", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/solution/policy.json": "62268c58729481cd02e159a3adf67badd0eef36d68be66228a588b7ffaf918c8", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-x-negotiation-site-test-s1/task.toml": "4022bf5969bf858fab5aca817c8a7f364e477d74056882b5b39195f6a653748b", + "tasks/ci-sharing-h2-x-negotiation-site-test-s1/task.toml": "3466d25a3372cc7f7b6699c08bc39fb5e63b080973fa5a61bcbcaf43b99add37", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/tests/expected.json": "0083aafe13c24f62966adb93d50ce0cbfaf63a5333004e1b96ef46319b5e3785", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-x-negotiation-site-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-x-negotiation-site-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-x-negotiation-site-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-x-negotiation-site-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/tests/scenario/episode.yaml": "52ca72727aa1937390d3b0686443a5ca2ef74820ba620b1e5ea0fad80971859d", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/tests/scenario/notes.md": "f19bdd9a154771bf7de8387311b3df0d69020b6d921437e7d85157c47a9188e1", "tasks/ci-sharing-h2-x-negotiation-site-test-s1/tests/scenario/record.json": "7ad0016efe0e4dac2abced1f0450d90e0f0c38970abb31c8f69e710f4bc922e4", @@ -5269,31 +5273,31 @@ "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/docker-compose.yaml": "ed967c609eba5f2243e773ea127f2c0f0d25435a07f88c066e2b9384904f3d3a", - "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/team/scenario/episode.yaml": "52ca72727aa1937390d3b0686443a5ca2ef74820ba620b1e5ea0fad80971859d", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/team/scenario/notes.md": "f19bdd9a154771bf7de8387311b3df0d69020b6d921437e7d85157c47a9188e1", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/team/scenario/record.json": "7ad0016efe0e4dac2abced1f0450d90e0f0c38970abb31c8f69e710f4bc922e4", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/team/scenario/source.md": "00e1af7d7db9397f6cbd5146fb1b30618abd20101b097d938e4012edce82a761", - "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/team/task.json": "aca55ea99de06c46af66c400ac05f065794b5048f07945a77feb42b051dd68e7", + "tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/team/task.json": "c4fad9e3db3c7af8f3e8d07e51c09e68f3ff9bc44647ce9c074c1c0a8aeb4208", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/instruction.md": "53d05baa22c2feda4fbddf1d07a6c820481351a366d2207da08b1586c7691897", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/solution/policy.json": "62268c58729481cd02e159a3adf67badd0eef36d68be66228a588b7ffaf918c8", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-h2-x-negotiation-site-test-s2/task.toml": "d0bead570e128fc0e3fcd05770e760cc5154841bf48d6d735543b1fb369554c6", + "tasks/ci-sharing-h2-x-negotiation-site-test-s2/task.toml": "38d1f647de053d3de566d2a128df9e02817adc199d58c1345d788a74c0641888", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/tests/expected.json": "e273c79f3c29775b24ecf06abe8c6dc390d74c8b06cba6d03542934eaec723d8", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-h2-x-negotiation-site-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-h2-x-negotiation-site-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-h2-x-negotiation-site-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-h2-x-negotiation-site-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/tests/scenario/episode.yaml": "52ca72727aa1937390d3b0686443a5ca2ef74820ba620b1e5ea0fad80971859d", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/tests/scenario/notes.md": "f19bdd9a154771bf7de8387311b3df0d69020b6d921437e7d85157c47a9188e1", "tasks/ci-sharing-h2-x-negotiation-site-test-s2/tests/scenario/record.json": "7ad0016efe0e4dac2abced1f0450d90e0f0c38970abb31c8f69e710f4bc922e4", @@ -5312,31 +5316,31 @@ "tasks/ci-sharing-l-lqts-father-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-l-lqts-father-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-l-lqts-father-solo-s0/environment/docker-compose.yaml": "166caacb6c06af91a3b9ba05cc9273e21fef984df44605afe15518f0a2efb417", - "tasks/ci-sharing-l-lqts-father-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-l-lqts-father-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-l-lqts-father-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-l-lqts-father-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-l-lqts-father-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-l-lqts-father-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-l-lqts-father-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-l-lqts-father-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-lqts-father-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-lqts-father-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-lqts-father-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-lqts-father-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-lqts-father-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-lqts-father-solo-s0/environment/team/scenario/episode.yaml": "908c8e551739aa4d684e815adec1a5f94b4fff275eca2184de43ef39ef329205", "tasks/ci-sharing-l-lqts-father-solo-s0/environment/team/scenario/notes.md": "4242818429ceb7a888516d8e132d159317de49ba8eeaa51a5c6c827e2c5a0883", "tasks/ci-sharing-l-lqts-father-solo-s0/environment/team/scenario/record.json": "e0cb700e887396545402d6afc6c795ba64fdaf282ee5cb4f41dc0551c94367a6", "tasks/ci-sharing-l-lqts-father-solo-s0/environment/team/scenario/source.md": "eb79f4fc503964b062b6a25ea369c0071ebcf3b2e17ca2b828cf6a0c773b4989", - "tasks/ci-sharing-l-lqts-father-solo-s0/environment/team/task.json": "63faa0bb09d5f6d835c453634000f77ba1fcc9ea78032271fc4a16e35fb2a6dd", + "tasks/ci-sharing-l-lqts-father-solo-s0/environment/team/task.json": "95d77ebd6e99ebb342ef3523c7b0e7de7220934d931ff3823f144bbc3cb9070d", "tasks/ci-sharing-l-lqts-father-solo-s0/instruction.md": "019b71e8a084731dfd59f55577c93761403d4ab00258428435370a95ccf50f85", "tasks/ci-sharing-l-lqts-father-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-l-lqts-father-solo-s0/solution/policy.json": "849492c8656d8c837b70acdc4d3c5e43d1c183d69daafe9c31c6ffd8fd733d70", "tasks/ci-sharing-l-lqts-father-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-l-lqts-father-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-l-lqts-father-solo-s0/task.toml": "5f62ee54500ba26314f591dd65949baf9db28270bd1da78b24d4dbeec35de1b3", + "tasks/ci-sharing-l-lqts-father-solo-s0/task.toml": "18449c2002cdb7fa78f78fdd7df9fbb1c7c9fd1acb5935bac61e45a3020c5b50", "tasks/ci-sharing-l-lqts-father-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-l-lqts-father-solo-s0/tests/expected.json": "6084e95091aaaf70d457f394c2cb1b81cdaa6f9c5f7b1af46cfc1cf8cf85ef6a", "tasks/ci-sharing-l-lqts-father-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-lqts-father-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-lqts-father-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-lqts-father-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-lqts-father-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-lqts-father-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-lqts-father-solo-s0/tests/scenario/episode.yaml": "908c8e551739aa4d684e815adec1a5f94b4fff275eca2184de43ef39ef329205", "tasks/ci-sharing-l-lqts-father-solo-s0/tests/scenario/notes.md": "4242818429ceb7a888516d8e132d159317de49ba8eeaa51a5c6c827e2c5a0883", "tasks/ci-sharing-l-lqts-father-solo-s0/tests/scenario/record.json": "e0cb700e887396545402d6afc6c795ba64fdaf282ee5cb4f41dc0551c94367a6", @@ -5355,31 +5359,31 @@ "tasks/ci-sharing-l-lqts-father-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-l-lqts-father-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-l-lqts-father-test-s0/environment/docker-compose.yaml": "aed4f368487b75d51b6e4895895765961132437217ef3840c4636e78a0ca1d3c", - "tasks/ci-sharing-l-lqts-father-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-l-lqts-father-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-l-lqts-father-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-l-lqts-father-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-l-lqts-father-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-l-lqts-father-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-l-lqts-father-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-l-lqts-father-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-lqts-father-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-lqts-father-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-lqts-father-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-lqts-father-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-lqts-father-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-lqts-father-test-s0/environment/team/scenario/episode.yaml": "908c8e551739aa4d684e815adec1a5f94b4fff275eca2184de43ef39ef329205", "tasks/ci-sharing-l-lqts-father-test-s0/environment/team/scenario/notes.md": "4242818429ceb7a888516d8e132d159317de49ba8eeaa51a5c6c827e2c5a0883", "tasks/ci-sharing-l-lqts-father-test-s0/environment/team/scenario/record.json": "e0cb700e887396545402d6afc6c795ba64fdaf282ee5cb4f41dc0551c94367a6", "tasks/ci-sharing-l-lqts-father-test-s0/environment/team/scenario/source.md": "eb79f4fc503964b062b6a25ea369c0071ebcf3b2e17ca2b828cf6a0c773b4989", - "tasks/ci-sharing-l-lqts-father-test-s0/environment/team/task.json": "d10c837d6a3dc30b26b7dbefe8d85e49656a49bd9f6d40d5fdafcb2891ccadac", + "tasks/ci-sharing-l-lqts-father-test-s0/environment/team/task.json": "fe756785f862df2b700a545c7133d48d8cea8a0514a0e25f38f98149f56c15bc", "tasks/ci-sharing-l-lqts-father-test-s0/instruction.md": "be08d79069e66ac1178a3d9f8d28fd29d6bf9aab02aa28fdc6c0d136a5f9d32f", "tasks/ci-sharing-l-lqts-father-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-l-lqts-father-test-s0/solution/policy.json": "849492c8656d8c837b70acdc4d3c5e43d1c183d69daafe9c31c6ffd8fd733d70", "tasks/ci-sharing-l-lqts-father-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-l-lqts-father-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-l-lqts-father-test-s0/task.toml": "c75110497832f023b4783a9655be2b3f28d927dce64c7c4ced23cd502727eb8d", + "tasks/ci-sharing-l-lqts-father-test-s0/task.toml": "f7f1291c70e61683a89d22a9c55f931cf48467f272b8032bbad93da4ad341122", "tasks/ci-sharing-l-lqts-father-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-l-lqts-father-test-s0/tests/expected.json": "cd8c03bd256b1f97112c789fb1459fd1973a38db6fb1e643cabd03fc164824a1", "tasks/ci-sharing-l-lqts-father-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-lqts-father-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-lqts-father-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-lqts-father-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-lqts-father-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-lqts-father-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-lqts-father-test-s0/tests/scenario/episode.yaml": "908c8e551739aa4d684e815adec1a5f94b4fff275eca2184de43ef39ef329205", "tasks/ci-sharing-l-lqts-father-test-s0/tests/scenario/notes.md": "4242818429ceb7a888516d8e132d159317de49ba8eeaa51a5c6c827e2c5a0883", "tasks/ci-sharing-l-lqts-father-test-s0/tests/scenario/record.json": "e0cb700e887396545402d6afc6c795ba64fdaf282ee5cb4f41dc0551c94367a6", @@ -5398,31 +5402,31 @@ "tasks/ci-sharing-l-lqts-father-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-l-lqts-father-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-l-lqts-father-test-s1/environment/docker-compose.yaml": "10436bab208dfcf20464fcea92901b52184d33c0dca7cc1ee8937d2d6dfeda0e", - "tasks/ci-sharing-l-lqts-father-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-l-lqts-father-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-l-lqts-father-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-l-lqts-father-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-l-lqts-father-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-l-lqts-father-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-l-lqts-father-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-l-lqts-father-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-lqts-father-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-lqts-father-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-lqts-father-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-lqts-father-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-lqts-father-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-lqts-father-test-s1/environment/team/scenario/episode.yaml": "908c8e551739aa4d684e815adec1a5f94b4fff275eca2184de43ef39ef329205", "tasks/ci-sharing-l-lqts-father-test-s1/environment/team/scenario/notes.md": "4242818429ceb7a888516d8e132d159317de49ba8eeaa51a5c6c827e2c5a0883", "tasks/ci-sharing-l-lqts-father-test-s1/environment/team/scenario/record.json": "e0cb700e887396545402d6afc6c795ba64fdaf282ee5cb4f41dc0551c94367a6", "tasks/ci-sharing-l-lqts-father-test-s1/environment/team/scenario/source.md": "eb79f4fc503964b062b6a25ea369c0071ebcf3b2e17ca2b828cf6a0c773b4989", - "tasks/ci-sharing-l-lqts-father-test-s1/environment/team/task.json": "6108335ab567efd92e3bd28b3c2e317feec526ed3a0bfe22fff3a422cba8c614", + "tasks/ci-sharing-l-lqts-father-test-s1/environment/team/task.json": "fc3b5b67a866bacdd2c61744dabd2e20fc3f766a1fad9e712923cd5366607604", "tasks/ci-sharing-l-lqts-father-test-s1/instruction.md": "be08d79069e66ac1178a3d9f8d28fd29d6bf9aab02aa28fdc6c0d136a5f9d32f", "tasks/ci-sharing-l-lqts-father-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-l-lqts-father-test-s1/solution/policy.json": "849492c8656d8c837b70acdc4d3c5e43d1c183d69daafe9c31c6ffd8fd733d70", "tasks/ci-sharing-l-lqts-father-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-l-lqts-father-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-l-lqts-father-test-s1/task.toml": "d171bb22e46a70300f1a31f89de4b7632ae984e3370f4b5c801189c67cbdff37", + "tasks/ci-sharing-l-lqts-father-test-s1/task.toml": "d9f81c4015d30af09a1185d1195db4bed2a601c02b4d1845876b189d130faa0a", "tasks/ci-sharing-l-lqts-father-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-l-lqts-father-test-s1/tests/expected.json": "3a898c74af952dfb09148434526c59c742b09ff84d49cfba3b333aeebd3d1d5d", "tasks/ci-sharing-l-lqts-father-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-lqts-father-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-lqts-father-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-lqts-father-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-lqts-father-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-lqts-father-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-lqts-father-test-s1/tests/scenario/episode.yaml": "908c8e551739aa4d684e815adec1a5f94b4fff275eca2184de43ef39ef329205", "tasks/ci-sharing-l-lqts-father-test-s1/tests/scenario/notes.md": "4242818429ceb7a888516d8e132d159317de49ba8eeaa51a5c6c827e2c5a0883", "tasks/ci-sharing-l-lqts-father-test-s1/tests/scenario/record.json": "e0cb700e887396545402d6afc6c795ba64fdaf282ee5cb4f41dc0551c94367a6", @@ -5441,31 +5445,31 @@ "tasks/ci-sharing-l-lqts-father-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-l-lqts-father-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-l-lqts-father-test-s2/environment/docker-compose.yaml": "123be49a3ef53c5330546e3bdd116ef294446482bec85a61556fd4bbcd8440ee", - "tasks/ci-sharing-l-lqts-father-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-l-lqts-father-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-l-lqts-father-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-l-lqts-father-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-l-lqts-father-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-l-lqts-father-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-l-lqts-father-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-l-lqts-father-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-lqts-father-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-lqts-father-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-lqts-father-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-lqts-father-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-lqts-father-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-lqts-father-test-s2/environment/team/scenario/episode.yaml": "908c8e551739aa4d684e815adec1a5f94b4fff275eca2184de43ef39ef329205", "tasks/ci-sharing-l-lqts-father-test-s2/environment/team/scenario/notes.md": "4242818429ceb7a888516d8e132d159317de49ba8eeaa51a5c6c827e2c5a0883", "tasks/ci-sharing-l-lqts-father-test-s2/environment/team/scenario/record.json": "e0cb700e887396545402d6afc6c795ba64fdaf282ee5cb4f41dc0551c94367a6", "tasks/ci-sharing-l-lqts-father-test-s2/environment/team/scenario/source.md": "eb79f4fc503964b062b6a25ea369c0071ebcf3b2e17ca2b828cf6a0c773b4989", - "tasks/ci-sharing-l-lqts-father-test-s2/environment/team/task.json": "9f8c7e7fef87d92fac569cc540ba3a4c3c67a469558e33392ae36983581e9389", + "tasks/ci-sharing-l-lqts-father-test-s2/environment/team/task.json": "6f5f934cc8b919d34ef20a808c0aff81a0bcce0cbd462c3fcfacbde2dce6c611", "tasks/ci-sharing-l-lqts-father-test-s2/instruction.md": "be08d79069e66ac1178a3d9f8d28fd29d6bf9aab02aa28fdc6c0d136a5f9d32f", "tasks/ci-sharing-l-lqts-father-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-l-lqts-father-test-s2/solution/policy.json": "849492c8656d8c837b70acdc4d3c5e43d1c183d69daafe9c31c6ffd8fd733d70", "tasks/ci-sharing-l-lqts-father-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-l-lqts-father-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-l-lqts-father-test-s2/task.toml": "1600d1ad4d79a405e094a9fa9959cbd37ba904ac0706b9f8d998b2384659c3e8", + "tasks/ci-sharing-l-lqts-father-test-s2/task.toml": "c8a8dc72bece222831ad4dc6564f7f8f09a9dab1a7ab4f1ce1648bd5d81ae1e8", "tasks/ci-sharing-l-lqts-father-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-l-lqts-father-test-s2/tests/expected.json": "84e0713aec35b12dc170069811a1478c72b8d5e1b167c20d2e398db86c18dd5b", "tasks/ci-sharing-l-lqts-father-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-lqts-father-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-lqts-father-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-lqts-father-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-lqts-father-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-lqts-father-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-lqts-father-test-s2/tests/scenario/episode.yaml": "908c8e551739aa4d684e815adec1a5f94b4fff275eca2184de43ef39ef329205", "tasks/ci-sharing-l-lqts-father-test-s2/tests/scenario/notes.md": "4242818429ceb7a888516d8e132d159317de49ba8eeaa51a5c6c827e2c5a0883", "tasks/ci-sharing-l-lqts-father-test-s2/tests/scenario/record.json": "e0cb700e887396545402d6afc6c795ba64fdaf282ee5cb4f41dc0551c94367a6", @@ -5484,31 +5488,31 @@ "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/docker-compose.yaml": "2dd79ca647726b3859a07cf1e4664cb8ac5a333699b400fdbf226dd2049401e5", - "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/team/scenario/episode.yaml": "ea403d2303cae27bdb9e58d7043493e727b49606f55c5bb0b92463ca0899427f", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/team/scenario/notes.md": "df7ddc75dd24ed7ba9ba03b2ad7d0053eaed82c02ce08146dfebb53ba25c50d5", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/team/scenario/record.json": "c0a3a3fca24b0c0099c8ab7e387a5879ec8331a0a3d7c95559fb320460040449", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/team/scenario/source.md": "8113e267be06220c1651dc9103495673cfc76151e4c31aec158abed10ce96b4c", - "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/team/task.json": "7c85b8e44eb9bcf203b01fbd63d731c30a57648dcddd158722c3ac9ce74ff118", + "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/team/task.json": "2a8b84c9e8e242a5295f948c5a695bfc39d2d94fde4a5d2833688bf7d50bc454", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/instruction.md": "0378f0376990476d0e411e8c6bd900c7741e0db366abd68a9f64587ae46d5304", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/solution/policy.json": "e5033802f36d56ad98999518a268c38a329daa69127c5250b59577343570bc42", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/task.toml": "dab2cc22e70d3d2d1cbe7cb001a64c7331bf3e6c292fd14093a5a12a22294b09", + "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/task.toml": "cc490936a095ee44778f91fa72654b080d7fad5b44eb9b7d006b77f4aa9afbca", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/tests/expected.json": "54cf4ecf43ba7888e8aacdeb89c5a6060aae8412cc82b68f27bcfe97607c9ce6", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/tests/scenario/episode.yaml": "ea403d2303cae27bdb9e58d7043493e727b49606f55c5bb0b92463ca0899427f", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/tests/scenario/notes.md": "df7ddc75dd24ed7ba9ba03b2ad7d0053eaed82c02ce08146dfebb53ba25c50d5", "tasks/ci-sharing-l-pregabalin-sachet-solo-s0/tests/scenario/record.json": "c0a3a3fca24b0c0099c8ab7e387a5879ec8331a0a3d7c95559fb320460040449", @@ -5527,31 +5531,31 @@ "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/docker-compose.yaml": "7d86f45bb06b88f114f080c2bbebf692e067fa2bb5f6fa20a252fb9c5428a8de", - "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/team/scenario/episode.yaml": "ea403d2303cae27bdb9e58d7043493e727b49606f55c5bb0b92463ca0899427f", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/team/scenario/notes.md": "df7ddc75dd24ed7ba9ba03b2ad7d0053eaed82c02ce08146dfebb53ba25c50d5", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/team/scenario/record.json": "c0a3a3fca24b0c0099c8ab7e387a5879ec8331a0a3d7c95559fb320460040449", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/team/scenario/source.md": "8113e267be06220c1651dc9103495673cfc76151e4c31aec158abed10ce96b4c", - "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/team/task.json": "c74ad7ed2e1ba0ff6ff49a1cbe3dcc3965314d87a19a7901996be95bb107c795", + "tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/team/task.json": "21d78db73f059cbfc48e0c738ba91beb20f63919154ac6240e097ee6f5fe6637", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/instruction.md": "5b615374ad0c4c0acd6cde8a4c89452251ab86879838feee55f2201c8869d9ec", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/solution/policy.json": "e5033802f36d56ad98999518a268c38a329daa69127c5250b59577343570bc42", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-l-pregabalin-sachet-test-s0/task.toml": "255f3d6d17f93145ab43da06590d640d71a5d3d03c06e48910389cfc83ff4876", + "tasks/ci-sharing-l-pregabalin-sachet-test-s0/task.toml": "d3676c7b2a1726a8fc01d84f2384b85e89497576c3d14db948dbc79ba9c6cc40", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/tests/expected.json": "eb955c4b26bc86bda4e4f395cb720721588aeef83e70e12f5abb46e01453cb26", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-pregabalin-sachet-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-pregabalin-sachet-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-pregabalin-sachet-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-pregabalin-sachet-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/tests/scenario/episode.yaml": "ea403d2303cae27bdb9e58d7043493e727b49606f55c5bb0b92463ca0899427f", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/tests/scenario/notes.md": "df7ddc75dd24ed7ba9ba03b2ad7d0053eaed82c02ce08146dfebb53ba25c50d5", "tasks/ci-sharing-l-pregabalin-sachet-test-s0/tests/scenario/record.json": "c0a3a3fca24b0c0099c8ab7e387a5879ec8331a0a3d7c95559fb320460040449", @@ -5570,31 +5574,31 @@ "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/docker-compose.yaml": "1da36c2d75c1a2a95f53c4b7a7c255ea64652e78c72ff91ade5d39d6eb32de96", - "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/team/scenario/episode.yaml": "ea403d2303cae27bdb9e58d7043493e727b49606f55c5bb0b92463ca0899427f", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/team/scenario/notes.md": "df7ddc75dd24ed7ba9ba03b2ad7d0053eaed82c02ce08146dfebb53ba25c50d5", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/team/scenario/record.json": "c0a3a3fca24b0c0099c8ab7e387a5879ec8331a0a3d7c95559fb320460040449", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/team/scenario/source.md": "8113e267be06220c1651dc9103495673cfc76151e4c31aec158abed10ce96b4c", - "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/team/task.json": "c615107e7d4832616848ec138524594e08ceb98c4fd9bf0068ea68d6d16b7fe8", + "tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/team/task.json": "6b22e238e8eec801d3a39711013472882cf9745a0a87099abf4637678eac57db", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/instruction.md": "5b615374ad0c4c0acd6cde8a4c89452251ab86879838feee55f2201c8869d9ec", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/solution/policy.json": "e5033802f36d56ad98999518a268c38a329daa69127c5250b59577343570bc42", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-l-pregabalin-sachet-test-s1/task.toml": "e61f8ff3dd6a0dbe37835f8af67467bf123dd2b4073a2dd7826c6abff755979a", + "tasks/ci-sharing-l-pregabalin-sachet-test-s1/task.toml": "054d8b3dd648b074c292b88d7779b4da44f0a72ab477bbf54668b60af46e404a", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/tests/expected.json": "f8785f2de228c984de9f23dd8ddff6965723fa527db1b5b3a914ef949cee11b1", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-pregabalin-sachet-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-pregabalin-sachet-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-pregabalin-sachet-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-pregabalin-sachet-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/tests/scenario/episode.yaml": "ea403d2303cae27bdb9e58d7043493e727b49606f55c5bb0b92463ca0899427f", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/tests/scenario/notes.md": "df7ddc75dd24ed7ba9ba03b2ad7d0053eaed82c02ce08146dfebb53ba25c50d5", "tasks/ci-sharing-l-pregabalin-sachet-test-s1/tests/scenario/record.json": "c0a3a3fca24b0c0099c8ab7e387a5879ec8331a0a3d7c95559fb320460040449", @@ -5613,31 +5617,31 @@ "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/docker-compose.yaml": "a8a0cf91b2c5e8273f1e5f409420d98039cc3389d134a5a9beabbd90afad6b5d", - "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/team/scenario/episode.yaml": "ea403d2303cae27bdb9e58d7043493e727b49606f55c5bb0b92463ca0899427f", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/team/scenario/notes.md": "df7ddc75dd24ed7ba9ba03b2ad7d0053eaed82c02ce08146dfebb53ba25c50d5", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/team/scenario/record.json": "c0a3a3fca24b0c0099c8ab7e387a5879ec8331a0a3d7c95559fb320460040449", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/team/scenario/source.md": "8113e267be06220c1651dc9103495673cfc76151e4c31aec158abed10ce96b4c", - "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/team/task.json": "0b4ccf23c6cd2f882962d39e27a938b5a27d1cc0574e069a5a316701f7ed67f2", + "tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/team/task.json": "f56b460d2ebca916c5c086f7f76c1b6340fe3b0536b8bb3f4ba0a747142b38ff", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/instruction.md": "5b615374ad0c4c0acd6cde8a4c89452251ab86879838feee55f2201c8869d9ec", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/solution/policy.json": "e5033802f36d56ad98999518a268c38a329daa69127c5250b59577343570bc42", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-l-pregabalin-sachet-test-s2/task.toml": "e292fcdcb88ad15eb65304ef501f7174cf04f9565fe5592039116caf08a6891c", + "tasks/ci-sharing-l-pregabalin-sachet-test-s2/task.toml": "334e84ba8298f58a6d3cd9634f9be010ea0ac2ed4eb815f8fb196ddadc0d6d57", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/tests/expected.json": "c6ee402dd5adcde8730be607669fa80f5ffc2fcc475d5f1346236e21adb81498", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-pregabalin-sachet-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-pregabalin-sachet-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-pregabalin-sachet-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-pregabalin-sachet-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/tests/scenario/episode.yaml": "ea403d2303cae27bdb9e58d7043493e727b49606f55c5bb0b92463ca0899427f", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/tests/scenario/notes.md": "df7ddc75dd24ed7ba9ba03b2ad7d0053eaed82c02ce08146dfebb53ba25c50d5", "tasks/ci-sharing-l-pregabalin-sachet-test-s2/tests/scenario/record.json": "c0a3a3fca24b0c0099c8ab7e387a5879ec8331a0a3d7c95559fb320460040449", @@ -5656,31 +5660,31 @@ "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/docker-compose.yaml": "2ec66cc1f5a19f129ae28382f3260bb3bb04327f250a41f2afd7677f86be0117", - "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/team/scenario/episode.yaml": "4ac8ae899b9920bf2e183234bedfc63d72dafe974dbc00a3446f85f8a357372f", "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/team/scenario/notes.md": "15ec90fec13ae0954d8364faaa8a01ad3d5af35ae576a8097c7f1f5d854339e6", "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/team/scenario/record.json": "04683efe4fa656e2a253d0456c0d013a2ddf62154654a1168d86f669ebc7c959", "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/team/scenario/source.md": "f7a3ea45ab03b76f9537444d13e1f1fa4f12f779dbdc8cb16363055728f34c4b", - "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/team/task.json": "1aef20727f7148fb68448fe3faff6dd59cc4fe2825a3423eda8d4a4cb318ae06", + "tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/team/task.json": "44a7406d0729d3511e544120a480a5c8927d1fc88b3ff069ee63c6d3f04c43fd", "tasks/ci-sharing-l-signout-drowsy-solo-s0/instruction.md": "8846e6b0431f838aabd3bab3d26d50d29e533811b868f01b883a4c0c05e7efdf", "tasks/ci-sharing-l-signout-drowsy-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-l-signout-drowsy-solo-s0/solution/policy.json": "0cfbb2965aaeb9186bdcea2e02b59d1bc51c75924545dbf01f741837d0db9928", "tasks/ci-sharing-l-signout-drowsy-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-l-signout-drowsy-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-l-signout-drowsy-solo-s0/task.toml": "e267eea596e45a8d0c6b82811479933a696a23bb05354488d98a6ca827ad4e46", + "tasks/ci-sharing-l-signout-drowsy-solo-s0/task.toml": "0ad27732fa7db94ebbc0462c4981fed508e366536db11196c5aa1a5691b77bc5", "tasks/ci-sharing-l-signout-drowsy-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-l-signout-drowsy-solo-s0/tests/expected.json": "998753af8148508459848a258ac9ca57d511353b0dd5559862c1ac510ebc55bc", "tasks/ci-sharing-l-signout-drowsy-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-signout-drowsy-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-signout-drowsy-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-signout-drowsy-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-signout-drowsy-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-signout-drowsy-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-signout-drowsy-solo-s0/tests/scenario/episode.yaml": "4ac8ae899b9920bf2e183234bedfc63d72dafe974dbc00a3446f85f8a357372f", "tasks/ci-sharing-l-signout-drowsy-solo-s0/tests/scenario/notes.md": "15ec90fec13ae0954d8364faaa8a01ad3d5af35ae576a8097c7f1f5d854339e6", "tasks/ci-sharing-l-signout-drowsy-solo-s0/tests/scenario/record.json": "04683efe4fa656e2a253d0456c0d013a2ddf62154654a1168d86f669ebc7c959", @@ -5699,31 +5703,31 @@ "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/docker-compose.yaml": "57d61577e02d52122eca877f10724cef3ea0040ab1cd5172b780bb549fc4ab33", - "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/team/scenario/episode.yaml": "4ac8ae899b9920bf2e183234bedfc63d72dafe974dbc00a3446f85f8a357372f", "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/team/scenario/notes.md": "15ec90fec13ae0954d8364faaa8a01ad3d5af35ae576a8097c7f1f5d854339e6", "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/team/scenario/record.json": "04683efe4fa656e2a253d0456c0d013a2ddf62154654a1168d86f669ebc7c959", "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/team/scenario/source.md": "f7a3ea45ab03b76f9537444d13e1f1fa4f12f779dbdc8cb16363055728f34c4b", - "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/team/task.json": "003cca543334a523c907b60b04e09e460d4f6474a86e6f9a121b37a94a589724", + "tasks/ci-sharing-l-signout-drowsy-test-s0/environment/team/task.json": "330f9836c48c608beadb9933a2cbc97b64924e32ce428ef99d3eaebfc580e16e", "tasks/ci-sharing-l-signout-drowsy-test-s0/instruction.md": "00f07120cb2b916716e726891566fe85f753ed8698f35f95c818669d7f8fe36b", "tasks/ci-sharing-l-signout-drowsy-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-l-signout-drowsy-test-s0/solution/policy.json": "0cfbb2965aaeb9186bdcea2e02b59d1bc51c75924545dbf01f741837d0db9928", "tasks/ci-sharing-l-signout-drowsy-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-l-signout-drowsy-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-l-signout-drowsy-test-s0/task.toml": "264fe44f73920cc33f644729ce61dc3cb5f821bd5a377cae9b3fb5c107ba9d3b", + "tasks/ci-sharing-l-signout-drowsy-test-s0/task.toml": "46df9d469780e2fd9f10537ffc9b4c1b137ee38b87df22cb18c3566ea2a6ce18", "tasks/ci-sharing-l-signout-drowsy-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-l-signout-drowsy-test-s0/tests/expected.json": "8c0463b6ec354d1e65eb32de2dc2678cb37638b25b5cb4973cb369749bb7a820", "tasks/ci-sharing-l-signout-drowsy-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-signout-drowsy-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-signout-drowsy-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-signout-drowsy-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-signout-drowsy-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-signout-drowsy-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-signout-drowsy-test-s0/tests/scenario/episode.yaml": "4ac8ae899b9920bf2e183234bedfc63d72dafe974dbc00a3446f85f8a357372f", "tasks/ci-sharing-l-signout-drowsy-test-s0/tests/scenario/notes.md": "15ec90fec13ae0954d8364faaa8a01ad3d5af35ae576a8097c7f1f5d854339e6", "tasks/ci-sharing-l-signout-drowsy-test-s0/tests/scenario/record.json": "04683efe4fa656e2a253d0456c0d013a2ddf62154654a1168d86f669ebc7c959", @@ -5742,31 +5746,31 @@ "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/docker-compose.yaml": "cfec843378189884cb204d4141086f9a83581a2873be7a238d6407333695e06d", - "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/team/scenario/episode.yaml": "4ac8ae899b9920bf2e183234bedfc63d72dafe974dbc00a3446f85f8a357372f", "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/team/scenario/notes.md": "15ec90fec13ae0954d8364faaa8a01ad3d5af35ae576a8097c7f1f5d854339e6", "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/team/scenario/record.json": "04683efe4fa656e2a253d0456c0d013a2ddf62154654a1168d86f669ebc7c959", "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/team/scenario/source.md": "f7a3ea45ab03b76f9537444d13e1f1fa4f12f779dbdc8cb16363055728f34c4b", - "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/team/task.json": "caa5c170b032724a723c85ebf258c1889ce18f5a8058c9ae81c9904025592875", + "tasks/ci-sharing-l-signout-drowsy-test-s1/environment/team/task.json": "c3f07774772bc42c7b9f8e068c8d87d5dad019c16ac4fcc32297ae2569b2afc4", "tasks/ci-sharing-l-signout-drowsy-test-s1/instruction.md": "00f07120cb2b916716e726891566fe85f753ed8698f35f95c818669d7f8fe36b", "tasks/ci-sharing-l-signout-drowsy-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-l-signout-drowsy-test-s1/solution/policy.json": "0cfbb2965aaeb9186bdcea2e02b59d1bc51c75924545dbf01f741837d0db9928", "tasks/ci-sharing-l-signout-drowsy-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-l-signout-drowsy-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-l-signout-drowsy-test-s1/task.toml": "a865c0d2ceedfdf2271035690a39a29602e60b045f21d51e28e23e1584eb218a", + "tasks/ci-sharing-l-signout-drowsy-test-s1/task.toml": "2f7e3fa0ccd907478d1736b30e5dc5c87f9a860f25569fc85012516b437042f3", "tasks/ci-sharing-l-signout-drowsy-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-l-signout-drowsy-test-s1/tests/expected.json": "0c8a020cddd2b3733e9eef05d6d64911bfc3fe7b74bf0bfdc5fb3a3200224104", "tasks/ci-sharing-l-signout-drowsy-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-signout-drowsy-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-signout-drowsy-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-signout-drowsy-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-signout-drowsy-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-signout-drowsy-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-signout-drowsy-test-s1/tests/scenario/episode.yaml": "4ac8ae899b9920bf2e183234bedfc63d72dafe974dbc00a3446f85f8a357372f", "tasks/ci-sharing-l-signout-drowsy-test-s1/tests/scenario/notes.md": "15ec90fec13ae0954d8364faaa8a01ad3d5af35ae576a8097c7f1f5d854339e6", "tasks/ci-sharing-l-signout-drowsy-test-s1/tests/scenario/record.json": "04683efe4fa656e2a253d0456c0d013a2ddf62154654a1168d86f669ebc7c959", @@ -5785,31 +5789,31 @@ "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/docker-compose.yaml": "01a51ef3036f00e99e730423d515be0dd9bb16b79cdb254cafb57125f0555376", - "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/team/scenario/episode.yaml": "4ac8ae899b9920bf2e183234bedfc63d72dafe974dbc00a3446f85f8a357372f", "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/team/scenario/notes.md": "15ec90fec13ae0954d8364faaa8a01ad3d5af35ae576a8097c7f1f5d854339e6", "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/team/scenario/record.json": "04683efe4fa656e2a253d0456c0d013a2ddf62154654a1168d86f669ebc7c959", "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/team/scenario/source.md": "f7a3ea45ab03b76f9537444d13e1f1fa4f12f779dbdc8cb16363055728f34c4b", - "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/team/task.json": "52a90be840cfdacf678595c2423b4389d1289c3e19795f4e51cbae7f50fbd630", + "tasks/ci-sharing-l-signout-drowsy-test-s2/environment/team/task.json": "3c62b685a6e6dd22a8952ac33a0bc210340db79756dae69074e45868ca63d51e", "tasks/ci-sharing-l-signout-drowsy-test-s2/instruction.md": "00f07120cb2b916716e726891566fe85f753ed8698f35f95c818669d7f8fe36b", "tasks/ci-sharing-l-signout-drowsy-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-l-signout-drowsy-test-s2/solution/policy.json": "0cfbb2965aaeb9186bdcea2e02b59d1bc51c75924545dbf01f741837d0db9928", "tasks/ci-sharing-l-signout-drowsy-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-l-signout-drowsy-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-l-signout-drowsy-test-s2/task.toml": "7af68ee9717c448641de2d42774cfe72e070607fccfaf644b1a48ab124f03937", + "tasks/ci-sharing-l-signout-drowsy-test-s2/task.toml": "01154b70d90d456bf0a244c474ec89836ac8c231f884c7b0af2e86a34a4e7561", "tasks/ci-sharing-l-signout-drowsy-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-l-signout-drowsy-test-s2/tests/expected.json": "4b2b9bbaaa6a8fb8b32a42c30246db17a6556199b4a57a64e5f44948dffee04d", "tasks/ci-sharing-l-signout-drowsy-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-signout-drowsy-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-signout-drowsy-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-signout-drowsy-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-signout-drowsy-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-signout-drowsy-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-signout-drowsy-test-s2/tests/scenario/episode.yaml": "4ac8ae899b9920bf2e183234bedfc63d72dafe974dbc00a3446f85f8a357372f", "tasks/ci-sharing-l-signout-drowsy-test-s2/tests/scenario/notes.md": "15ec90fec13ae0954d8364faaa8a01ad3d5af35ae576a8097c7f1f5d854339e6", "tasks/ci-sharing-l-signout-drowsy-test-s2/tests/scenario/record.json": "04683efe4fa656e2a253d0456c0d013a2ddf62154654a1168d86f669ebc7c959", @@ -5828,31 +5832,31 @@ "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/docker-compose.yaml": "f885dbd5722049f11fa8c43ae646940d029af8b673b1f59e5011188b3d9506f3", - "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/team/scenario/episode.yaml": "4609631ebf79836c3db74523544245cabdefabd1b6657fc9470d164b37de2e8f", "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/team/scenario/notes.md": "9ddb98a5b620f96e4927e8158acf3d44bd216d9806293998b92ef1245fa9d1e1", "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/team/scenario/record.json": "5ee0c577ef58b9bf02b20142b0ae238cd72b7c07cbae7a27ae9a211441dfd4b0", "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/team/scenario/source.md": "b194e54c133e4e1cfe9677a356d3cb57fee4491e022272cb2decbdd2041b2399", - "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/team/task.json": "f6f6f52c476573b7b1af11ea95a7fd95dff85c250d3e82df0f9ed728899f6a9e", + "tasks/ci-sharing-l-storm-advisory-solo-s0/environment/team/task.json": "0bd3dfb12980932a2eb7227b3cbd49ee8fd5d579f1bbfc125864eb61234a9045", "tasks/ci-sharing-l-storm-advisory-solo-s0/instruction.md": "c8e9d6d48897412dfb4ad3079adff8d2f4751111394682da6766e4a4f3d68c20", "tasks/ci-sharing-l-storm-advisory-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-l-storm-advisory-solo-s0/solution/policy.json": "a7e58d0439a8c7a6a5dfd78d8eaecce7af11cb0b94daab1065ba01cbd447593a", "tasks/ci-sharing-l-storm-advisory-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-l-storm-advisory-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-l-storm-advisory-solo-s0/task.toml": "7ffea76752ecc773855294a0f1059f57fe0b86ddd3ca17da05bbf9d337f5dc28", + "tasks/ci-sharing-l-storm-advisory-solo-s0/task.toml": "b0292a5788b2c295e52ec410bea265492f52bb3c992ff7960228eb6e3d52166d", "tasks/ci-sharing-l-storm-advisory-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-l-storm-advisory-solo-s0/tests/expected.json": "6f818edde0c61182dece5bf1719b0918b4cb43928e3bdf005db27c84bc1704e8", "tasks/ci-sharing-l-storm-advisory-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-storm-advisory-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-storm-advisory-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-storm-advisory-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-storm-advisory-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-storm-advisory-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-storm-advisory-solo-s0/tests/scenario/episode.yaml": "4609631ebf79836c3db74523544245cabdefabd1b6657fc9470d164b37de2e8f", "tasks/ci-sharing-l-storm-advisory-solo-s0/tests/scenario/notes.md": "9ddb98a5b620f96e4927e8158acf3d44bd216d9806293998b92ef1245fa9d1e1", "tasks/ci-sharing-l-storm-advisory-solo-s0/tests/scenario/record.json": "5ee0c577ef58b9bf02b20142b0ae238cd72b7c07cbae7a27ae9a211441dfd4b0", @@ -5871,31 +5875,31 @@ "tasks/ci-sharing-l-storm-advisory-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-l-storm-advisory-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-l-storm-advisory-test-s0/environment/docker-compose.yaml": "e84e8b7d212ee60bc8bf2e2b68ca2f3aa9b7839143a44eea01067b34988ac80e", - "tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/scenario/episode.yaml": "4609631ebf79836c3db74523544245cabdefabd1b6657fc9470d164b37de2e8f", "tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/scenario/notes.md": "9ddb98a5b620f96e4927e8158acf3d44bd216d9806293998b92ef1245fa9d1e1", "tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/scenario/record.json": "5ee0c577ef58b9bf02b20142b0ae238cd72b7c07cbae7a27ae9a211441dfd4b0", "tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/scenario/source.md": "b194e54c133e4e1cfe9677a356d3cb57fee4491e022272cb2decbdd2041b2399", - "tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/task.json": "16bd363a9858233f8ac034d0024c42da64b5b478ff7c89cf6db8a19309fbea77", + "tasks/ci-sharing-l-storm-advisory-test-s0/environment/team/task.json": "b7fe6fda9bbeee76b049a0ba2c6a032ca0168821464a1b2a056807ecef857334", "tasks/ci-sharing-l-storm-advisory-test-s0/instruction.md": "352f048cf348d3e965885fecc6d3d54e808c09afbfd1d26ff08dde578cbfdb3d", "tasks/ci-sharing-l-storm-advisory-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-l-storm-advisory-test-s0/solution/policy.json": "a7e58d0439a8c7a6a5dfd78d8eaecce7af11cb0b94daab1065ba01cbd447593a", "tasks/ci-sharing-l-storm-advisory-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-l-storm-advisory-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-l-storm-advisory-test-s0/task.toml": "122e3a4c5ddb17dbcab5f497701df3229ba61120e3c7e59659da13f67bcd659c", + "tasks/ci-sharing-l-storm-advisory-test-s0/task.toml": "60e18aa8f785424ee0edf9dffe56b599f1ddf618dc0881c85493df4024b49b93", "tasks/ci-sharing-l-storm-advisory-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-l-storm-advisory-test-s0/tests/expected.json": "c1016d518464d14a698b2b811b976d65f047cb5c6f78ddfdfdf75bcd02b7e922", "tasks/ci-sharing-l-storm-advisory-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-storm-advisory-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-storm-advisory-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-storm-advisory-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-storm-advisory-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-storm-advisory-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-storm-advisory-test-s0/tests/scenario/episode.yaml": "4609631ebf79836c3db74523544245cabdefabd1b6657fc9470d164b37de2e8f", "tasks/ci-sharing-l-storm-advisory-test-s0/tests/scenario/notes.md": "9ddb98a5b620f96e4927e8158acf3d44bd216d9806293998b92ef1245fa9d1e1", "tasks/ci-sharing-l-storm-advisory-test-s0/tests/scenario/record.json": "5ee0c577ef58b9bf02b20142b0ae238cd72b7c07cbae7a27ae9a211441dfd4b0", @@ -5914,31 +5918,31 @@ "tasks/ci-sharing-l-storm-advisory-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-l-storm-advisory-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-l-storm-advisory-test-s1/environment/docker-compose.yaml": "078ff89ca6de37468e0c2a271df03f3aae549437c1ff2b2c8012aa0487c3271b", - "tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/scenario/episode.yaml": "4609631ebf79836c3db74523544245cabdefabd1b6657fc9470d164b37de2e8f", "tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/scenario/notes.md": "9ddb98a5b620f96e4927e8158acf3d44bd216d9806293998b92ef1245fa9d1e1", "tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/scenario/record.json": "5ee0c577ef58b9bf02b20142b0ae238cd72b7c07cbae7a27ae9a211441dfd4b0", "tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/scenario/source.md": "b194e54c133e4e1cfe9677a356d3cb57fee4491e022272cb2decbdd2041b2399", - "tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/task.json": "ed5d2fd4a059a57ca01761ce1d9e818367047ec6460086295f32c66d8fe7a668", + "tasks/ci-sharing-l-storm-advisory-test-s1/environment/team/task.json": "3d71c59384c3b5f51a053904df5ad82657e7d224b34cbb29ddc2a835694b5ce7", "tasks/ci-sharing-l-storm-advisory-test-s1/instruction.md": "352f048cf348d3e965885fecc6d3d54e808c09afbfd1d26ff08dde578cbfdb3d", "tasks/ci-sharing-l-storm-advisory-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-l-storm-advisory-test-s1/solution/policy.json": "a7e58d0439a8c7a6a5dfd78d8eaecce7af11cb0b94daab1065ba01cbd447593a", "tasks/ci-sharing-l-storm-advisory-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-l-storm-advisory-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-l-storm-advisory-test-s1/task.toml": "a06fb51b078783c9d78dfc7b33f94cf4b685c9299a34103c7099d5416a7f14d0", + "tasks/ci-sharing-l-storm-advisory-test-s1/task.toml": "0f0f455c09aa3c914065fe46b4565d45956c3cffee3c81b12988edb53ceb55c1", "tasks/ci-sharing-l-storm-advisory-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-l-storm-advisory-test-s1/tests/expected.json": "5d165be971eddb370c8231cfeaa5d91373b0425387a9931ebd8f67a067959efd", "tasks/ci-sharing-l-storm-advisory-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-storm-advisory-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-storm-advisory-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-storm-advisory-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-storm-advisory-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-storm-advisory-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-storm-advisory-test-s1/tests/scenario/episode.yaml": "4609631ebf79836c3db74523544245cabdefabd1b6657fc9470d164b37de2e8f", "tasks/ci-sharing-l-storm-advisory-test-s1/tests/scenario/notes.md": "9ddb98a5b620f96e4927e8158acf3d44bd216d9806293998b92ef1245fa9d1e1", "tasks/ci-sharing-l-storm-advisory-test-s1/tests/scenario/record.json": "5ee0c577ef58b9bf02b20142b0ae238cd72b7c07cbae7a27ae9a211441dfd4b0", @@ -5957,31 +5961,31 @@ "tasks/ci-sharing-l-storm-advisory-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-l-storm-advisory-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-l-storm-advisory-test-s2/environment/docker-compose.yaml": "afa86d4602a9645622f9fea6850c1a83bc22cde43192765190b2c3c5817bbb6c", - "tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/scenario/episode.yaml": "4609631ebf79836c3db74523544245cabdefabd1b6657fc9470d164b37de2e8f", "tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/scenario/notes.md": "9ddb98a5b620f96e4927e8158acf3d44bd216d9806293998b92ef1245fa9d1e1", "tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/scenario/record.json": "5ee0c577ef58b9bf02b20142b0ae238cd72b7c07cbae7a27ae9a211441dfd4b0", "tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/scenario/source.md": "b194e54c133e4e1cfe9677a356d3cb57fee4491e022272cb2decbdd2041b2399", - "tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/task.json": "257d2cee1723bbd179fa1a0e6f40cc142d764d41ca62a82c711f4c8924ab1737", + "tasks/ci-sharing-l-storm-advisory-test-s2/environment/team/task.json": "982f4bfec63d007936bc7e65d11644d121868de5ee44d045a0761d9ed35df606", "tasks/ci-sharing-l-storm-advisory-test-s2/instruction.md": "352f048cf348d3e965885fecc6d3d54e808c09afbfd1d26ff08dde578cbfdb3d", "tasks/ci-sharing-l-storm-advisory-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-l-storm-advisory-test-s2/solution/policy.json": "a7e58d0439a8c7a6a5dfd78d8eaecce7af11cb0b94daab1065ba01cbd447593a", "tasks/ci-sharing-l-storm-advisory-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-l-storm-advisory-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-l-storm-advisory-test-s2/task.toml": "31b79df3438a578859c5cbdf051427eb4fc137892720483a4ee09ca89088b0e6", + "tasks/ci-sharing-l-storm-advisory-test-s2/task.toml": "996cdf3a37fd6d0395ae04e8d297f4fc63790d35f05ed13c03ff788d19f93793", "tasks/ci-sharing-l-storm-advisory-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-l-storm-advisory-test-s2/tests/expected.json": "989f756014b2723c2d9365e76e9486ec8f75c1a62a68b8442012de695aded50a", "tasks/ci-sharing-l-storm-advisory-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-l-storm-advisory-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-l-storm-advisory-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-l-storm-advisory-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-l-storm-advisory-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-l-storm-advisory-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-l-storm-advisory-test-s2/tests/scenario/episode.yaml": "4609631ebf79836c3db74523544245cabdefabd1b6657fc9470d164b37de2e8f", "tasks/ci-sharing-l-storm-advisory-test-s2/tests/scenario/notes.md": "9ddb98a5b620f96e4927e8158acf3d44bd216d9806293998b92ef1245fa9d1e1", "tasks/ci-sharing-l-storm-advisory-test-s2/tests/scenario/record.json": "5ee0c577ef58b9bf02b20142b0ae238cd72b7c07cbae7a27ae9a211441dfd4b0", @@ -6000,32 +6004,32 @@ "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/docker-compose.yaml": "ae1bd9774439e94d5a97c194ca38bdef4a2bc5fc2d7d9227cb35cae0dd3d73bf", - "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/scenario/episode.yaml": "fd1f8933f866ecc74a357e693b23e1814543d72b87b0171ced28046815a1ebe5", "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/scenario/notes.md": "aedf48d17a1baeb1c5d8673cb3b8c6ff7d8ed9c85b9ae3dea616df18511f7699", "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/scenario/record.json": "46771164ab14e3e2d03d81f31bc2877274a9664d85d1c64203f5ccfeeb8553a9", "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/scenario/source.md": "df21a203951bcdcf799cfd184919365fd8c02f16517c9355a19c2e5849061cfa", "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/scenario/source_raw/math_row.json": "a83f7956acbdb5b5a5a147213d989eafb9b17f93c1b86344095d9eab6e862d64", - "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/task.json": "e9cfe0402ab1050bed5e625b152583f9f1ff2aa9fa27d00b2c26ffb01f5de8e8", + "tasks/ci-sharing-n-jersey-teams-solo-s0/environment/team/task.json": "9e1e8e1e3d946441f19b28765d7e7c1bfb3f01bb683ca8da201cdf4e71c209ad", "tasks/ci-sharing-n-jersey-teams-solo-s0/instruction.md": "023af92319840078e7dff355331d0c4e6c734271fd1ceb6481a08b94e5ed9606", "tasks/ci-sharing-n-jersey-teams-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-n-jersey-teams-solo-s0/solution/policy.json": "b995418deb39b1be9cc3bfc1180202e4440c882e3c178e308f88f506ea554cc5", "tasks/ci-sharing-n-jersey-teams-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-n-jersey-teams-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-n-jersey-teams-solo-s0/task.toml": "ad0268f097fe0b05dcb611bfb498aed70b3f50b0e9f52e958863de6af347ee25", + "tasks/ci-sharing-n-jersey-teams-solo-s0/task.toml": "6e6ee269ab74d9514cfad1f44944b649a0a2729d0612ae0288f035dea0af0a06", "tasks/ci-sharing-n-jersey-teams-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-n-jersey-teams-solo-s0/tests/expected.json": "47b00b9220dd151f71ccfda08acebb359edc39be38499f93b30c5886545b3ca2", "tasks/ci-sharing-n-jersey-teams-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-jersey-teams-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-jersey-teams-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-jersey-teams-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-jersey-teams-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-jersey-teams-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-jersey-teams-solo-s0/tests/scenario/episode.yaml": "fd1f8933f866ecc74a357e693b23e1814543d72b87b0171ced28046815a1ebe5", "tasks/ci-sharing-n-jersey-teams-solo-s0/tests/scenario/notes.md": "aedf48d17a1baeb1c5d8673cb3b8c6ff7d8ed9c85b9ae3dea616df18511f7699", "tasks/ci-sharing-n-jersey-teams-solo-s0/tests/scenario/record.json": "46771164ab14e3e2d03d81f31bc2877274a9664d85d1c64203f5ccfeeb8553a9", @@ -6045,32 +6049,32 @@ "tasks/ci-sharing-n-jersey-teams-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-n-jersey-teams-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-n-jersey-teams-test-s0/environment/docker-compose.yaml": "95d0b74a88054b02116fef585f979ef709b0b1a5d2c66cda5309a316bccc7b4e", - "tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/scenario/episode.yaml": "fd1f8933f866ecc74a357e693b23e1814543d72b87b0171ced28046815a1ebe5", "tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/scenario/notes.md": "aedf48d17a1baeb1c5d8673cb3b8c6ff7d8ed9c85b9ae3dea616df18511f7699", "tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/scenario/record.json": "46771164ab14e3e2d03d81f31bc2877274a9664d85d1c64203f5ccfeeb8553a9", "tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/scenario/source.md": "df21a203951bcdcf799cfd184919365fd8c02f16517c9355a19c2e5849061cfa", "tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/scenario/source_raw/math_row.json": "a83f7956acbdb5b5a5a147213d989eafb9b17f93c1b86344095d9eab6e862d64", - "tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/task.json": "ab83f2ab2148de41ce7f1232af80ff8e5e286b24b70c5fc9ec6c5520b044360b", + "tasks/ci-sharing-n-jersey-teams-test-s0/environment/team/task.json": "f26bf1ddb4f72619dac75a2af7b03c8647124dc612123ac960828cc11a289631", "tasks/ci-sharing-n-jersey-teams-test-s0/instruction.md": "c3aec7331f673332a2ac2d65757afe5deb2d13c90a5a967536f326675bb46ddc", "tasks/ci-sharing-n-jersey-teams-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-n-jersey-teams-test-s0/solution/policy.json": "4ddc888cb275f9a00b1f2f8ac870f630b7d2e6c4697d7ccc6abf48eabd6f33a6", "tasks/ci-sharing-n-jersey-teams-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-n-jersey-teams-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-n-jersey-teams-test-s0/task.toml": "023e2af6d4da3650bee6880bd94c4a81ed84fc3a5984afe2eb9f58b0b65ff75b", + "tasks/ci-sharing-n-jersey-teams-test-s0/task.toml": "3aaddbe8af0299e27e64c0277ec9e53f246f4987a04fdfcb227feb2b06c2125e", "tasks/ci-sharing-n-jersey-teams-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-n-jersey-teams-test-s0/tests/expected.json": "bc9af2d2c3d01089477e4498632c5820d2f7911a531f8a5945fe149f223a736c", "tasks/ci-sharing-n-jersey-teams-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-jersey-teams-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-jersey-teams-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-jersey-teams-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-jersey-teams-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-jersey-teams-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-jersey-teams-test-s0/tests/scenario/episode.yaml": "fd1f8933f866ecc74a357e693b23e1814543d72b87b0171ced28046815a1ebe5", "tasks/ci-sharing-n-jersey-teams-test-s0/tests/scenario/notes.md": "aedf48d17a1baeb1c5d8673cb3b8c6ff7d8ed9c85b9ae3dea616df18511f7699", "tasks/ci-sharing-n-jersey-teams-test-s0/tests/scenario/record.json": "46771164ab14e3e2d03d81f31bc2877274a9664d85d1c64203f5ccfeeb8553a9", @@ -6090,32 +6094,32 @@ "tasks/ci-sharing-n-jersey-teams-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-n-jersey-teams-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-n-jersey-teams-test-s1/environment/docker-compose.yaml": "d0cbe067250dfa241c6fe08eb7c0b26a41db6be1c8e7b2452e69923e62b62073", - "tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/scenario/episode.yaml": "fd1f8933f866ecc74a357e693b23e1814543d72b87b0171ced28046815a1ebe5", "tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/scenario/notes.md": "aedf48d17a1baeb1c5d8673cb3b8c6ff7d8ed9c85b9ae3dea616df18511f7699", "tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/scenario/record.json": "46771164ab14e3e2d03d81f31bc2877274a9664d85d1c64203f5ccfeeb8553a9", "tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/scenario/source.md": "df21a203951bcdcf799cfd184919365fd8c02f16517c9355a19c2e5849061cfa", "tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/scenario/source_raw/math_row.json": "a83f7956acbdb5b5a5a147213d989eafb9b17f93c1b86344095d9eab6e862d64", - "tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/task.json": "f30d981930c91077d7f283ff298a225e20aa614ea8a05b39f4beb26330307e28", + "tasks/ci-sharing-n-jersey-teams-test-s1/environment/team/task.json": "b6f2db2b293c547f6b56122ce6d65cd4db6ee65552d3a500081ea61cca46025c", "tasks/ci-sharing-n-jersey-teams-test-s1/instruction.md": "c3aec7331f673332a2ac2d65757afe5deb2d13c90a5a967536f326675bb46ddc", "tasks/ci-sharing-n-jersey-teams-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-n-jersey-teams-test-s1/solution/policy.json": "4ddc888cb275f9a00b1f2f8ac870f630b7d2e6c4697d7ccc6abf48eabd6f33a6", "tasks/ci-sharing-n-jersey-teams-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-n-jersey-teams-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-n-jersey-teams-test-s1/task.toml": "0ecc83352c6a4bbccb9b051e316d68903a1a7955d392f4a2533f5c8f661ce9d7", + "tasks/ci-sharing-n-jersey-teams-test-s1/task.toml": "da37f7235c6f12a94bc90d0825e14776855e718e32416bf1928b71ef78b3e333", "tasks/ci-sharing-n-jersey-teams-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-n-jersey-teams-test-s1/tests/expected.json": "8df980a5f6027784ef0da3d119745a42e064f136838fa190e5a06f8d2bcd15f1", "tasks/ci-sharing-n-jersey-teams-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-jersey-teams-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-jersey-teams-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-jersey-teams-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-jersey-teams-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-jersey-teams-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-jersey-teams-test-s1/tests/scenario/episode.yaml": "fd1f8933f866ecc74a357e693b23e1814543d72b87b0171ced28046815a1ebe5", "tasks/ci-sharing-n-jersey-teams-test-s1/tests/scenario/notes.md": "aedf48d17a1baeb1c5d8673cb3b8c6ff7d8ed9c85b9ae3dea616df18511f7699", "tasks/ci-sharing-n-jersey-teams-test-s1/tests/scenario/record.json": "46771164ab14e3e2d03d81f31bc2877274a9664d85d1c64203f5ccfeeb8553a9", @@ -6135,32 +6139,32 @@ "tasks/ci-sharing-n-jersey-teams-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-n-jersey-teams-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-n-jersey-teams-test-s2/environment/docker-compose.yaml": "d1ed671db34a5e058513c074d797507b79ff5f888e8c2607d316abc2b6721999", - "tasks/ci-sharing-n-jersey-teams-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-n-jersey-teams-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-n-jersey-teams-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-n-jersey-teams-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-n-jersey-teams-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-n-jersey-teams-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-n-jersey-teams-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-n-jersey-teams-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-jersey-teams-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-jersey-teams-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-jersey-teams-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-jersey-teams-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-jersey-teams-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-jersey-teams-test-s2/environment/team/scenario/episode.yaml": "fd1f8933f866ecc74a357e693b23e1814543d72b87b0171ced28046815a1ebe5", "tasks/ci-sharing-n-jersey-teams-test-s2/environment/team/scenario/notes.md": "aedf48d17a1baeb1c5d8673cb3b8c6ff7d8ed9c85b9ae3dea616df18511f7699", "tasks/ci-sharing-n-jersey-teams-test-s2/environment/team/scenario/record.json": "46771164ab14e3e2d03d81f31bc2877274a9664d85d1c64203f5ccfeeb8553a9", "tasks/ci-sharing-n-jersey-teams-test-s2/environment/team/scenario/source.md": "df21a203951bcdcf799cfd184919365fd8c02f16517c9355a19c2e5849061cfa", "tasks/ci-sharing-n-jersey-teams-test-s2/environment/team/scenario/source_raw/math_row.json": "a83f7956acbdb5b5a5a147213d989eafb9b17f93c1b86344095d9eab6e862d64", - "tasks/ci-sharing-n-jersey-teams-test-s2/environment/team/task.json": "d46718fecdd7fcd1f172b40bbcee36e68b9a8945ebf8eb2b0d66351af747b987", + "tasks/ci-sharing-n-jersey-teams-test-s2/environment/team/task.json": "1feb56374f301d2e9565b57a556c1fe099aa0e86005619353d1951a408035c75", "tasks/ci-sharing-n-jersey-teams-test-s2/instruction.md": "c3aec7331f673332a2ac2d65757afe5deb2d13c90a5a967536f326675bb46ddc", "tasks/ci-sharing-n-jersey-teams-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-n-jersey-teams-test-s2/solution/policy.json": "4ddc888cb275f9a00b1f2f8ac870f630b7d2e6c4697d7ccc6abf48eabd6f33a6", "tasks/ci-sharing-n-jersey-teams-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-n-jersey-teams-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-n-jersey-teams-test-s2/task.toml": "053c59638a37931a22e00e493b1d88905434e8de7ba03fceb31aec0bbc890527", + "tasks/ci-sharing-n-jersey-teams-test-s2/task.toml": "2a812aefd87c816b2e2f2804d5236f4701f60f936f970088858144e39a82fef7", "tasks/ci-sharing-n-jersey-teams-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-n-jersey-teams-test-s2/tests/expected.json": "e2ba21d050ae1311ac95bc614331d120b6834288aee6c9d61d34ab2201cf2a20", "tasks/ci-sharing-n-jersey-teams-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-jersey-teams-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-jersey-teams-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-jersey-teams-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-jersey-teams-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-jersey-teams-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-jersey-teams-test-s2/tests/scenario/episode.yaml": "fd1f8933f866ecc74a357e693b23e1814543d72b87b0171ced28046815a1ebe5", "tasks/ci-sharing-n-jersey-teams-test-s2/tests/scenario/notes.md": "aedf48d17a1baeb1c5d8673cb3b8c6ff7d8ed9c85b9ae3dea616df18511f7699", "tasks/ci-sharing-n-jersey-teams-test-s2/tests/scenario/record.json": "46771164ab14e3e2d03d81f31bc2877274a9664d85d1c64203f5ccfeeb8553a9", @@ -6180,32 +6184,32 @@ "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/docker-compose.yaml": "c5173eb3b7933b58dd0bec3ab8fc71729e64dc2e07f00fdab07382ed7560e8f4", - "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/team/scenario/episode.yaml": "2b4d5393f0415f595ac30a29d10e024a9e9da553cd1b3b6b95838c8fdac4796b", "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/team/scenario/notes.md": "389b50e7a463b506270e3ccfb93cc335c49750c9d32dba81c6e3e875ed2d4014", "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/team/scenario/record.json": "d834753b63c239c80a2b1a21f6017ce599a64e0399592fa2fb76f59eaf42cb0a", "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/team/scenario/source.md": "50b2b75754f065f7f309b34f464a3c41f252e5a5648a699f2645f6e95ae1c74a", "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/team/scenario/source_raw/math_row.json": "eb6472d3e741ba1b7c3cd594336bc1f18b5609f56dca0b44b7849f88b00f642e", - "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/team/task.json": "e1b912e7cb63c0c0c682b31f778aefca2a6e4a83a17d348ceecac2502dfbf41e", + "tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/team/task.json": "2c76be448cb0cdd7f94e3acde3d5c2dd32136807f508235ca812bd3657140dff", "tasks/ci-sharing-n-palindrome-bound-solo-s0/instruction.md": "47f393fd1ffae6e0c6f90ce11428b5dca65b74ef366708da62c60a0c5f7dd0cf", "tasks/ci-sharing-n-palindrome-bound-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-n-palindrome-bound-solo-s0/solution/policy.json": "19115f4b98d0a0c1a4ed99d8b0782949982564e227107b450878ecd869bb4e18", "tasks/ci-sharing-n-palindrome-bound-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-n-palindrome-bound-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-n-palindrome-bound-solo-s0/task.toml": "c17edd8932634b14524aa56d8cbc8f45937c6f51ea73a9d522ae503517166148", + "tasks/ci-sharing-n-palindrome-bound-solo-s0/task.toml": "cf63bc25d8f5e749169b86c8a9fd50caf7f6068279ed1b4717daf3427e7987c8", "tasks/ci-sharing-n-palindrome-bound-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-n-palindrome-bound-solo-s0/tests/expected.json": "849a2807c4943c30d0d1171a63e6749b929d0823af0c37b02f908be14a7e3f9f", "tasks/ci-sharing-n-palindrome-bound-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-palindrome-bound-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-palindrome-bound-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-palindrome-bound-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-palindrome-bound-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-palindrome-bound-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-palindrome-bound-solo-s0/tests/scenario/episode.yaml": "2b4d5393f0415f595ac30a29d10e024a9e9da553cd1b3b6b95838c8fdac4796b", "tasks/ci-sharing-n-palindrome-bound-solo-s0/tests/scenario/notes.md": "389b50e7a463b506270e3ccfb93cc335c49750c9d32dba81c6e3e875ed2d4014", "tasks/ci-sharing-n-palindrome-bound-solo-s0/tests/scenario/record.json": "d834753b63c239c80a2b1a21f6017ce599a64e0399592fa2fb76f59eaf42cb0a", @@ -6225,32 +6229,32 @@ "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/docker-compose.yaml": "b737c319396c50e6ba1a741feee87203b2bf9587daea009061c7ff8b0e12339d", - "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/team/scenario/episode.yaml": "2b4d5393f0415f595ac30a29d10e024a9e9da553cd1b3b6b95838c8fdac4796b", "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/team/scenario/notes.md": "389b50e7a463b506270e3ccfb93cc335c49750c9d32dba81c6e3e875ed2d4014", "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/team/scenario/record.json": "d834753b63c239c80a2b1a21f6017ce599a64e0399592fa2fb76f59eaf42cb0a", "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/team/scenario/source.md": "50b2b75754f065f7f309b34f464a3c41f252e5a5648a699f2645f6e95ae1c74a", "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/team/scenario/source_raw/math_row.json": "eb6472d3e741ba1b7c3cd594336bc1f18b5609f56dca0b44b7849f88b00f642e", - "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/team/task.json": "0e2dc330a9ed2120bfaff9cc2d9a8a831273950e7d24b43b81162f7b0e956b44", + "tasks/ci-sharing-n-palindrome-bound-test-s0/environment/team/task.json": "335be54415caf962a48dd860ffd42c68c4ee9d1811e0edba6246e32db3604171", "tasks/ci-sharing-n-palindrome-bound-test-s0/instruction.md": "2f5bfd65277f7303c758235bb36ed6a3028f157578f6effd0252b3121aee9141", "tasks/ci-sharing-n-palindrome-bound-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-n-palindrome-bound-test-s0/solution/policy.json": "7341ec25d4a51eea6644c55152bc64775d5a1c94522c481e41cbc00244a1407a", "tasks/ci-sharing-n-palindrome-bound-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-n-palindrome-bound-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-n-palindrome-bound-test-s0/task.toml": "ee58f9b7701e955eb0f503f2b64e872c5ddc96f6d0e014add09c13cbd109238f", + "tasks/ci-sharing-n-palindrome-bound-test-s0/task.toml": "1deb2c3292c3de7c64c3f965768f4e9ea3453dbff4621b245a24d5fa727043b3", "tasks/ci-sharing-n-palindrome-bound-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-n-palindrome-bound-test-s0/tests/expected.json": "abe2ebb82e20a7fed92e8f6518f6f800f4d303d11ec805829d5a2891a028b704", "tasks/ci-sharing-n-palindrome-bound-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-palindrome-bound-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-palindrome-bound-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-palindrome-bound-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-palindrome-bound-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-palindrome-bound-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-palindrome-bound-test-s0/tests/scenario/episode.yaml": "2b4d5393f0415f595ac30a29d10e024a9e9da553cd1b3b6b95838c8fdac4796b", "tasks/ci-sharing-n-palindrome-bound-test-s0/tests/scenario/notes.md": "389b50e7a463b506270e3ccfb93cc335c49750c9d32dba81c6e3e875ed2d4014", "tasks/ci-sharing-n-palindrome-bound-test-s0/tests/scenario/record.json": "d834753b63c239c80a2b1a21f6017ce599a64e0399592fa2fb76f59eaf42cb0a", @@ -6270,32 +6274,32 @@ "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/docker-compose.yaml": "ff3190a0d24918e1251d777c76a247b10cdbf1ba1ef507ff4d8aa6121ad831c4", - "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/team/scenario/episode.yaml": "2b4d5393f0415f595ac30a29d10e024a9e9da553cd1b3b6b95838c8fdac4796b", "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/team/scenario/notes.md": "389b50e7a463b506270e3ccfb93cc335c49750c9d32dba81c6e3e875ed2d4014", "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/team/scenario/record.json": "d834753b63c239c80a2b1a21f6017ce599a64e0399592fa2fb76f59eaf42cb0a", "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/team/scenario/source.md": "50b2b75754f065f7f309b34f464a3c41f252e5a5648a699f2645f6e95ae1c74a", "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/team/scenario/source_raw/math_row.json": "eb6472d3e741ba1b7c3cd594336bc1f18b5609f56dca0b44b7849f88b00f642e", - "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/team/task.json": "500ced4c0c725139d00ba97364b50d2e8909e1836a7cf04f575eec6ead15ced0", + "tasks/ci-sharing-n-palindrome-bound-test-s1/environment/team/task.json": "da2339c7a1f76f575c61769c3a2d410b869bac751718f84cf57c25179b4ccebf", "tasks/ci-sharing-n-palindrome-bound-test-s1/instruction.md": "2f5bfd65277f7303c758235bb36ed6a3028f157578f6effd0252b3121aee9141", "tasks/ci-sharing-n-palindrome-bound-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-n-palindrome-bound-test-s1/solution/policy.json": "7341ec25d4a51eea6644c55152bc64775d5a1c94522c481e41cbc00244a1407a", "tasks/ci-sharing-n-palindrome-bound-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-n-palindrome-bound-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-n-palindrome-bound-test-s1/task.toml": "5c36456c6d5f48f8375a59db5cade941546deb1b5ed9237d47228e0d9f39ac1f", + "tasks/ci-sharing-n-palindrome-bound-test-s1/task.toml": "6736c8ab0cde8a509ff93f8178887c1ee3a99064657383de818a595b81ab5107", "tasks/ci-sharing-n-palindrome-bound-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-n-palindrome-bound-test-s1/tests/expected.json": "be28489815551ef4a2ac598ff43105f24a2baf35adaafa0d314b2a7f955de6c7", "tasks/ci-sharing-n-palindrome-bound-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-palindrome-bound-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-palindrome-bound-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-palindrome-bound-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-palindrome-bound-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-palindrome-bound-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-palindrome-bound-test-s1/tests/scenario/episode.yaml": "2b4d5393f0415f595ac30a29d10e024a9e9da553cd1b3b6b95838c8fdac4796b", "tasks/ci-sharing-n-palindrome-bound-test-s1/tests/scenario/notes.md": "389b50e7a463b506270e3ccfb93cc335c49750c9d32dba81c6e3e875ed2d4014", "tasks/ci-sharing-n-palindrome-bound-test-s1/tests/scenario/record.json": "d834753b63c239c80a2b1a21f6017ce599a64e0399592fa2fb76f59eaf42cb0a", @@ -6315,32 +6319,32 @@ "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/docker-compose.yaml": "67c64fc89ad89e73d972ab4274935a086315b9dbf936f5f59ed86b445ebe2015", - "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/team/scenario/episode.yaml": "2b4d5393f0415f595ac30a29d10e024a9e9da553cd1b3b6b95838c8fdac4796b", "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/team/scenario/notes.md": "389b50e7a463b506270e3ccfb93cc335c49750c9d32dba81c6e3e875ed2d4014", "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/team/scenario/record.json": "d834753b63c239c80a2b1a21f6017ce599a64e0399592fa2fb76f59eaf42cb0a", "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/team/scenario/source.md": "50b2b75754f065f7f309b34f464a3c41f252e5a5648a699f2645f6e95ae1c74a", "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/team/scenario/source_raw/math_row.json": "eb6472d3e741ba1b7c3cd594336bc1f18b5609f56dca0b44b7849f88b00f642e", - "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/team/task.json": "40d621eb14c38e3e9dadba7f18dc96f8fdccfc7e0ada8fa066de16c6e809f1c7", + "tasks/ci-sharing-n-palindrome-bound-test-s2/environment/team/task.json": "f6aa01eb646401ef5af62f387ac9f3f9cc5aadbf6d89cb0d7a6405b1dbd8741e", "tasks/ci-sharing-n-palindrome-bound-test-s2/instruction.md": "2f5bfd65277f7303c758235bb36ed6a3028f157578f6effd0252b3121aee9141", "tasks/ci-sharing-n-palindrome-bound-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-n-palindrome-bound-test-s2/solution/policy.json": "7341ec25d4a51eea6644c55152bc64775d5a1c94522c481e41cbc00244a1407a", "tasks/ci-sharing-n-palindrome-bound-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-n-palindrome-bound-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-n-palindrome-bound-test-s2/task.toml": "afbf4ea5cd6d76386a5793ce0059e4c71f401792a2d73d8c983588144b90f80f", + "tasks/ci-sharing-n-palindrome-bound-test-s2/task.toml": "46cb947f0fda259e7362d404de1022c658103033a041deaf4a06968a2daf4461", "tasks/ci-sharing-n-palindrome-bound-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-n-palindrome-bound-test-s2/tests/expected.json": "dfbba852b441236a1489aaf5f198afdee213f6dcafe182d8409c9c1a009a0aa2", "tasks/ci-sharing-n-palindrome-bound-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-palindrome-bound-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-palindrome-bound-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-palindrome-bound-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-palindrome-bound-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-palindrome-bound-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-palindrome-bound-test-s2/tests/scenario/episode.yaml": "2b4d5393f0415f595ac30a29d10e024a9e9da553cd1b3b6b95838c8fdac4796b", "tasks/ci-sharing-n-palindrome-bound-test-s2/tests/scenario/notes.md": "389b50e7a463b506270e3ccfb93cc335c49750c9d32dba81c6e3e875ed2d4014", "tasks/ci-sharing-n-palindrome-bound-test-s2/tests/scenario/record.json": "d834753b63c239c80a2b1a21f6017ce599a64e0399592fa2fb76f59eaf42cb0a", @@ -6360,31 +6364,31 @@ "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/docker-compose.yaml": "e16c487a04a8d3b979a60fda8cf0f1376e38ca718791495aac8bd7395ab64adc", - "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/team/scenario/episode.yaml": "c43f98d5a619dbdf623312ac3fafdf1e9b2f73125fc6c5c4cf4cc9007d980182", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/team/scenario/notes.md": "30cd589f33888c55e1d2856d4713a82a436745c0781a74a67c98ffb0525e131a", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/team/scenario/record.json": "e9c2bc8792f5b148b583f4d35a9abead796079dfba1db4049a11e8beb027d452", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/team/scenario/source.md": "4b9c703b97d675bbf672e0c8d92a1ab9c737673d597c8b7614d4f9fdf822a2aa", - "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/team/task.json": "04dd00644883e5d8eed86c50954308e36f013dd89895c9ea0fc438a29798da87", + "tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/team/task.json": "95aa227fdb80898fd40c8a4c7c9e532744859877f73b04abc383900bbaac2543", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/instruction.md": "0c52807e68afe21fae512f6d160308a3737d17979b405deee72e252f90148de4", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/solution/policy.json": "40319681e47cd1dd93a7c5c5224b83248312b28e98e1e72b9e071b48dc84538e", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-n-tamponade-alternans-solo-s0/task.toml": "eb79b80ec029b758bfedd5a9ab0424930bb82989d00f75e3a2578757c70a4c7b", + "tasks/ci-sharing-n-tamponade-alternans-solo-s0/task.toml": "ee0f37ba7d4d28881717f535707695e27da187daf0581ed88b7b698904524703", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/tests/expected.json": "f15f9c94c6f1c2d543df9b7ac29a05c011ed97fc44d7342975bd6e015f333e28", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-tamponade-alternans-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-tamponade-alternans-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-tamponade-alternans-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-tamponade-alternans-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/tests/scenario/episode.yaml": "c43f98d5a619dbdf623312ac3fafdf1e9b2f73125fc6c5c4cf4cc9007d980182", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/tests/scenario/notes.md": "30cd589f33888c55e1d2856d4713a82a436745c0781a74a67c98ffb0525e131a", "tasks/ci-sharing-n-tamponade-alternans-solo-s0/tests/scenario/record.json": "e9c2bc8792f5b148b583f4d35a9abead796079dfba1db4049a11e8beb027d452", @@ -6403,31 +6407,31 @@ "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/docker-compose.yaml": "4c81b487cd1fbe23ec9ded3e7765cb86e66a203470ac576c2606cccd4f5c9e09", - "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/team/scenario/episode.yaml": "c43f98d5a619dbdf623312ac3fafdf1e9b2f73125fc6c5c4cf4cc9007d980182", "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/team/scenario/notes.md": "30cd589f33888c55e1d2856d4713a82a436745c0781a74a67c98ffb0525e131a", "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/team/scenario/record.json": "e9c2bc8792f5b148b583f4d35a9abead796079dfba1db4049a11e8beb027d452", "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/team/scenario/source.md": "4b9c703b97d675bbf672e0c8d92a1ab9c737673d597c8b7614d4f9fdf822a2aa", - "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/team/task.json": "94a769b9e0809b57d802d7c5cb640b3767569065e25c455c95b691ed9f89c76c", + "tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/team/task.json": "d249408718cdc5b3956bed6ce09bad01081acf83726d18f636d2371f5d3e1f63", "tasks/ci-sharing-n-tamponade-alternans-test-s0/instruction.md": "8e2eb91235761e8f0b2bbcd7c2425aff820740f65dd8da37ad49f5712cc826d3", "tasks/ci-sharing-n-tamponade-alternans-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-n-tamponade-alternans-test-s0/solution/policy.json": "40319681e47cd1dd93a7c5c5224b83248312b28e98e1e72b9e071b48dc84538e", "tasks/ci-sharing-n-tamponade-alternans-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-n-tamponade-alternans-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-n-tamponade-alternans-test-s0/task.toml": "594ec220f9859a1dff073c73d5b61483c475c6f6a6ec65dcf65ebc242ba50d91", + "tasks/ci-sharing-n-tamponade-alternans-test-s0/task.toml": "7571fafc1e4f2cf3d4d28712996f818eaba45fbdb3da1edaeddf7c44360fcc5a", "tasks/ci-sharing-n-tamponade-alternans-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-n-tamponade-alternans-test-s0/tests/expected.json": "eecce989a01eb650796a535237f2e9189d65397060d290f4033f4018cf4a0bd6", "tasks/ci-sharing-n-tamponade-alternans-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-tamponade-alternans-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-tamponade-alternans-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-tamponade-alternans-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-tamponade-alternans-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-tamponade-alternans-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-tamponade-alternans-test-s0/tests/scenario/episode.yaml": "c43f98d5a619dbdf623312ac3fafdf1e9b2f73125fc6c5c4cf4cc9007d980182", "tasks/ci-sharing-n-tamponade-alternans-test-s0/tests/scenario/notes.md": "30cd589f33888c55e1d2856d4713a82a436745c0781a74a67c98ffb0525e131a", "tasks/ci-sharing-n-tamponade-alternans-test-s0/tests/scenario/record.json": "e9c2bc8792f5b148b583f4d35a9abead796079dfba1db4049a11e8beb027d452", @@ -6446,31 +6450,31 @@ "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/docker-compose.yaml": "c5c7b4082f66d14c413f059da535d436dff28689caec46a0f019d729b552dec8", - "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/team/scenario/episode.yaml": "c43f98d5a619dbdf623312ac3fafdf1e9b2f73125fc6c5c4cf4cc9007d980182", "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/team/scenario/notes.md": "30cd589f33888c55e1d2856d4713a82a436745c0781a74a67c98ffb0525e131a", "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/team/scenario/record.json": "e9c2bc8792f5b148b583f4d35a9abead796079dfba1db4049a11e8beb027d452", "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/team/scenario/source.md": "4b9c703b97d675bbf672e0c8d92a1ab9c737673d597c8b7614d4f9fdf822a2aa", - "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/team/task.json": "676e73ee399b59ffaa78cf08d1de5243b900977d50fb991714b1cbdd95cc912e", + "tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/team/task.json": "973810e14a02d79cc75924426826e47e71e323edb29e90932c966a2b599d421f", "tasks/ci-sharing-n-tamponade-alternans-test-s1/instruction.md": "8e2eb91235761e8f0b2bbcd7c2425aff820740f65dd8da37ad49f5712cc826d3", "tasks/ci-sharing-n-tamponade-alternans-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-n-tamponade-alternans-test-s1/solution/policy.json": "40319681e47cd1dd93a7c5c5224b83248312b28e98e1e72b9e071b48dc84538e", "tasks/ci-sharing-n-tamponade-alternans-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-n-tamponade-alternans-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-n-tamponade-alternans-test-s1/task.toml": "402c2f353ccaee8d8c8214e1ae65341452f4fe72f300e58e0c96dcb60451728c", + "tasks/ci-sharing-n-tamponade-alternans-test-s1/task.toml": "4984e3f3a344709404e7e1b92c8c90afb91b5dc18bef00344900715c1e99495d", "tasks/ci-sharing-n-tamponade-alternans-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-n-tamponade-alternans-test-s1/tests/expected.json": "848cc15e27cc2dc805a82e2e05c299fba677b2b1d2e6dfa958e5a1cb10558370", "tasks/ci-sharing-n-tamponade-alternans-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-tamponade-alternans-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-tamponade-alternans-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-tamponade-alternans-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-tamponade-alternans-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-tamponade-alternans-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-tamponade-alternans-test-s1/tests/scenario/episode.yaml": "c43f98d5a619dbdf623312ac3fafdf1e9b2f73125fc6c5c4cf4cc9007d980182", "tasks/ci-sharing-n-tamponade-alternans-test-s1/tests/scenario/notes.md": "30cd589f33888c55e1d2856d4713a82a436745c0781a74a67c98ffb0525e131a", "tasks/ci-sharing-n-tamponade-alternans-test-s1/tests/scenario/record.json": "e9c2bc8792f5b148b583f4d35a9abead796079dfba1db4049a11e8beb027d452", @@ -6489,31 +6493,31 @@ "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/docker-compose.yaml": "0d7c6f5c9021d522aa1bdca17cbb67f3f9aeaba389661115d29eeafcb0fd15cf", - "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/team/scenario/episode.yaml": "c43f98d5a619dbdf623312ac3fafdf1e9b2f73125fc6c5c4cf4cc9007d980182", "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/team/scenario/notes.md": "30cd589f33888c55e1d2856d4713a82a436745c0781a74a67c98ffb0525e131a", "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/team/scenario/record.json": "e9c2bc8792f5b148b583f4d35a9abead796079dfba1db4049a11e8beb027d452", "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/team/scenario/source.md": "4b9c703b97d675bbf672e0c8d92a1ab9c737673d597c8b7614d4f9fdf822a2aa", - "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/team/task.json": "df2d36666bca0244b7709e67b92c8f60607123be8b3d7affa33d96b575b79dc6", + "tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/team/task.json": "3fc98fc642a490ec435d06a3c2e90b932471e5cca6d68e78e2bc04e225cd8a29", "tasks/ci-sharing-n-tamponade-alternans-test-s2/instruction.md": "8e2eb91235761e8f0b2bbcd7c2425aff820740f65dd8da37ad49f5712cc826d3", "tasks/ci-sharing-n-tamponade-alternans-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-n-tamponade-alternans-test-s2/solution/policy.json": "40319681e47cd1dd93a7c5c5224b83248312b28e98e1e72b9e071b48dc84538e", "tasks/ci-sharing-n-tamponade-alternans-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-n-tamponade-alternans-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-n-tamponade-alternans-test-s2/task.toml": "00b779cc8b215cb916209a9986c0ecf95b98182d9cf1e0540dcc0d7b30a0fcfd", + "tasks/ci-sharing-n-tamponade-alternans-test-s2/task.toml": "a7eb70619292f3b6c3bada8e219eb5cdeb61cca2856376b613aeade16c2447b9", "tasks/ci-sharing-n-tamponade-alternans-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-n-tamponade-alternans-test-s2/tests/expected.json": "661b17aa80f0c03409f960b8dbef5b9157964690236adcb66a33b475e5d44166", "tasks/ci-sharing-n-tamponade-alternans-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-tamponade-alternans-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-tamponade-alternans-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-tamponade-alternans-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-tamponade-alternans-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-tamponade-alternans-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-tamponade-alternans-test-s2/tests/scenario/episode.yaml": "c43f98d5a619dbdf623312ac3fafdf1e9b2f73125fc6c5c4cf4cc9007d980182", "tasks/ci-sharing-n-tamponade-alternans-test-s2/tests/scenario/notes.md": "30cd589f33888c55e1d2856d4713a82a436745c0781a74a67c98ffb0525e131a", "tasks/ci-sharing-n-tamponade-alternans-test-s2/tests/scenario/record.json": "e9c2bc8792f5b148b583f4d35a9abead796079dfba1db4049a11e8beb027d452", @@ -6532,20 +6536,20 @@ "tasks/ci-sharing-n-triangle-area-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-n-triangle-area-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-n-triangle-area-solo-s0/environment/docker-compose.yaml": "221f0b8fbebdc5478531fe834c7e3147a5728891b7bc0944e8d186a4d4674e60", - "tasks/ci-sharing-n-triangle-area-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-n-triangle-area-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-n-triangle-area-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-n-triangle-area-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-n-triangle-area-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-n-triangle-area-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-n-triangle-area-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-n-triangle-area-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-triangle-area-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-triangle-area-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-triangle-area-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-triangle-area-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-triangle-area-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-triangle-area-solo-s0/environment/team/scenario/episode.yaml": "71f2a6fb0d550baa6eec320e96f8313488820404e4875b2a2775871a4a16e0bb", "tasks/ci-sharing-n-triangle-area-solo-s0/environment/team/scenario/notes.md": "7bd1afd0a0ec693abb829e271076f9823d7532c1ea4d1047f9afc771b47b13d2", "tasks/ci-sharing-n-triangle-area-solo-s0/environment/team/scenario/record.json": "780ee0d360bc395c32a17c1458e2f930848773e5456dc55de0e0823af42cf28d", "tasks/ci-sharing-n-triangle-area-solo-s0/environment/team/scenario/source.md": "ed28347a399eca3476a58acf3348ec59720c1f31943ad09fade47a421def582c", "tasks/ci-sharing-n-triangle-area-solo-s0/environment/team/scenario/source_raw/humaneval_row.json": "077fe47c1c49ee61b2983cd423793a5fb737bcf421bfacdf8975d75858c142ec", - "tasks/ci-sharing-n-triangle-area-solo-s0/environment/team/task.json": "9a7106feac86d8e88f975b62908a4f8c2af8c8e2f9c77d26be402ca6f59c5da4", + "tasks/ci-sharing-n-triangle-area-solo-s0/environment/team/task.json": "267e9e60c12ca66ec99029b0f39d6f77447f32da9b91f85ee7c6124bce675527", "tasks/ci-sharing-n-triangle-area-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-sharing-n-triangle-area-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-sharing-n-triangle-area-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -6559,13 +6563,13 @@ "tasks/ci-sharing-n-triangle-area-solo-s0/solution/policy.json": "da9bc994fb836befbb556f1849379da9c87d5aa236acd59f11359c3269aeec13", "tasks/ci-sharing-n-triangle-area-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-n-triangle-area-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-n-triangle-area-solo-s0/task.toml": "741b62df8f6dbf5aa7d45885bdd4503d54f22b135c011f4e04ef77004761b981", + "tasks/ci-sharing-n-triangle-area-solo-s0/task.toml": "f41645c6ab35d19afbfe7683e6494b6b21704e7a20106aed8613202fd13544bd", "tasks/ci-sharing-n-triangle-area-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-n-triangle-area-solo-s0/tests/expected.json": "6d65670d783b7dedc80438daadc856aecb71ac593acfe8ba815fa6859289568e", "tasks/ci-sharing-n-triangle-area-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-triangle-area-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-triangle-area-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-triangle-area-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-triangle-area-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-triangle-area-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-triangle-area-solo-s0/tests/scenario/episode.yaml": "71f2a6fb0d550baa6eec320e96f8313488820404e4875b2a2775871a4a16e0bb", "tasks/ci-sharing-n-triangle-area-solo-s0/tests/scenario/notes.md": "7bd1afd0a0ec693abb829e271076f9823d7532c1ea4d1047f9afc771b47b13d2", "tasks/ci-sharing-n-triangle-area-solo-s0/tests/scenario/record.json": "780ee0d360bc395c32a17c1458e2f930848773e5456dc55de0e0823af42cf28d", @@ -6585,20 +6589,20 @@ "tasks/ci-sharing-n-triangle-area-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-n-triangle-area-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-n-triangle-area-test-s0/environment/docker-compose.yaml": "a4c35f54bbfea16eff9c4fb6c23eddb0ba281e18e1b996b6d6c73ca157bc93e8", - "tasks/ci-sharing-n-triangle-area-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-n-triangle-area-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-n-triangle-area-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-n-triangle-area-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-n-triangle-area-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-n-triangle-area-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-n-triangle-area-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-n-triangle-area-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-triangle-area-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-triangle-area-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-triangle-area-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-triangle-area-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-triangle-area-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-triangle-area-test-s0/environment/team/scenario/episode.yaml": "71f2a6fb0d550baa6eec320e96f8313488820404e4875b2a2775871a4a16e0bb", "tasks/ci-sharing-n-triangle-area-test-s0/environment/team/scenario/notes.md": "7bd1afd0a0ec693abb829e271076f9823d7532c1ea4d1047f9afc771b47b13d2", "tasks/ci-sharing-n-triangle-area-test-s0/environment/team/scenario/record.json": "780ee0d360bc395c32a17c1458e2f930848773e5456dc55de0e0823af42cf28d", "tasks/ci-sharing-n-triangle-area-test-s0/environment/team/scenario/source.md": "ed28347a399eca3476a58acf3348ec59720c1f31943ad09fade47a421def582c", "tasks/ci-sharing-n-triangle-area-test-s0/environment/team/scenario/source_raw/humaneval_row.json": "077fe47c1c49ee61b2983cd423793a5fb737bcf421bfacdf8975d75858c142ec", - "tasks/ci-sharing-n-triangle-area-test-s0/environment/team/task.json": "d3af76f98e6f6fc792b2cf32d8b20974c6fb89f635a50e3cd26929c15b17ba7d", + "tasks/ci-sharing-n-triangle-area-test-s0/environment/team/task.json": "94b1b5e77f6c983c16a8310b515718ec34f267902484d867e2934bb551f05656", "tasks/ci-sharing-n-triangle-area-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-sharing-n-triangle-area-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-sharing-n-triangle-area-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -6612,13 +6616,13 @@ "tasks/ci-sharing-n-triangle-area-test-s0/solution/policy.json": "ea674111870ed8f9124f6057fdcfba16302c0e8740e14a322e71ac16946d9dea", "tasks/ci-sharing-n-triangle-area-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-n-triangle-area-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-n-triangle-area-test-s0/task.toml": "db2122adb44a0d376c7501eeb0a1b11dd656491bec5f112890bd6457fd12cd7d", + "tasks/ci-sharing-n-triangle-area-test-s0/task.toml": "0fa3b8b4c08c62b035c606172a675797bddf926123a46272317151980bb92d52", "tasks/ci-sharing-n-triangle-area-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-n-triangle-area-test-s0/tests/expected.json": "26195a73067dd56fafff7d5f21244f1c82bc5ec84c98e5042e64080085b3b0e5", "tasks/ci-sharing-n-triangle-area-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-triangle-area-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-triangle-area-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-triangle-area-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-triangle-area-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-triangle-area-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-triangle-area-test-s0/tests/scenario/episode.yaml": "71f2a6fb0d550baa6eec320e96f8313488820404e4875b2a2775871a4a16e0bb", "tasks/ci-sharing-n-triangle-area-test-s0/tests/scenario/notes.md": "7bd1afd0a0ec693abb829e271076f9823d7532c1ea4d1047f9afc771b47b13d2", "tasks/ci-sharing-n-triangle-area-test-s0/tests/scenario/record.json": "780ee0d360bc395c32a17c1458e2f930848773e5456dc55de0e0823af42cf28d", @@ -6638,20 +6642,20 @@ "tasks/ci-sharing-n-triangle-area-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-n-triangle-area-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-n-triangle-area-test-s1/environment/docker-compose.yaml": "893aec915336a7c6eb39c335cde77598c408781f4d24927fe8fc47bdaabccd4e", - "tasks/ci-sharing-n-triangle-area-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-n-triangle-area-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-n-triangle-area-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-n-triangle-area-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-n-triangle-area-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-n-triangle-area-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-n-triangle-area-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-n-triangle-area-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-triangle-area-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-triangle-area-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-triangle-area-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-triangle-area-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-triangle-area-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-triangle-area-test-s1/environment/team/scenario/episode.yaml": "71f2a6fb0d550baa6eec320e96f8313488820404e4875b2a2775871a4a16e0bb", "tasks/ci-sharing-n-triangle-area-test-s1/environment/team/scenario/notes.md": "7bd1afd0a0ec693abb829e271076f9823d7532c1ea4d1047f9afc771b47b13d2", "tasks/ci-sharing-n-triangle-area-test-s1/environment/team/scenario/record.json": "780ee0d360bc395c32a17c1458e2f930848773e5456dc55de0e0823af42cf28d", "tasks/ci-sharing-n-triangle-area-test-s1/environment/team/scenario/source.md": "ed28347a399eca3476a58acf3348ec59720c1f31943ad09fade47a421def582c", "tasks/ci-sharing-n-triangle-area-test-s1/environment/team/scenario/source_raw/humaneval_row.json": "077fe47c1c49ee61b2983cd423793a5fb737bcf421bfacdf8975d75858c142ec", - "tasks/ci-sharing-n-triangle-area-test-s1/environment/team/task.json": "8ec889f51114dfa5d052136408766de416db27aa120698657d8a9724c4a8013a", + "tasks/ci-sharing-n-triangle-area-test-s1/environment/team/task.json": "cd3e67bdfe74cb9ef330667e41aa4463f35215314b2274ba6be6a13b9fb0ae95", "tasks/ci-sharing-n-triangle-area-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-sharing-n-triangle-area-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-sharing-n-triangle-area-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -6665,13 +6669,13 @@ "tasks/ci-sharing-n-triangle-area-test-s1/solution/policy.json": "ea674111870ed8f9124f6057fdcfba16302c0e8740e14a322e71ac16946d9dea", "tasks/ci-sharing-n-triangle-area-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-n-triangle-area-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-n-triangle-area-test-s1/task.toml": "253aa0ec309c7f95a8a02596d1e0d237cea6b1dbc887191fb9763cfc3ad965be", + "tasks/ci-sharing-n-triangle-area-test-s1/task.toml": "1432eeec8f9f897463a52a3b23c85b50bf92623a0a0394a224af0af346c97006", "tasks/ci-sharing-n-triangle-area-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-n-triangle-area-test-s1/tests/expected.json": "dcbad3937d177cfe4db84fbb4708231639ff650082d1c84fddbd04471e9da786", "tasks/ci-sharing-n-triangle-area-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-triangle-area-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-triangle-area-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-triangle-area-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-triangle-area-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-triangle-area-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-triangle-area-test-s1/tests/scenario/episode.yaml": "71f2a6fb0d550baa6eec320e96f8313488820404e4875b2a2775871a4a16e0bb", "tasks/ci-sharing-n-triangle-area-test-s1/tests/scenario/notes.md": "7bd1afd0a0ec693abb829e271076f9823d7532c1ea4d1047f9afc771b47b13d2", "tasks/ci-sharing-n-triangle-area-test-s1/tests/scenario/record.json": "780ee0d360bc395c32a17c1458e2f930848773e5456dc55de0e0823af42cf28d", @@ -6691,20 +6695,20 @@ "tasks/ci-sharing-n-triangle-area-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-n-triangle-area-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-n-triangle-area-test-s2/environment/docker-compose.yaml": "9a72b15f6df8b812771e54a1de4a6951968826f0db8aeca55528e9925fa53e5a", - "tasks/ci-sharing-n-triangle-area-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-n-triangle-area-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-n-triangle-area-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-n-triangle-area-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-n-triangle-area-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-n-triangle-area-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-n-triangle-area-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-n-triangle-area-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-triangle-area-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-triangle-area-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-triangle-area-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-triangle-area-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-triangle-area-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-triangle-area-test-s2/environment/team/scenario/episode.yaml": "71f2a6fb0d550baa6eec320e96f8313488820404e4875b2a2775871a4a16e0bb", "tasks/ci-sharing-n-triangle-area-test-s2/environment/team/scenario/notes.md": "7bd1afd0a0ec693abb829e271076f9823d7532c1ea4d1047f9afc771b47b13d2", "tasks/ci-sharing-n-triangle-area-test-s2/environment/team/scenario/record.json": "780ee0d360bc395c32a17c1458e2f930848773e5456dc55de0e0823af42cf28d", "tasks/ci-sharing-n-triangle-area-test-s2/environment/team/scenario/source.md": "ed28347a399eca3476a58acf3348ec59720c1f31943ad09fade47a421def582c", "tasks/ci-sharing-n-triangle-area-test-s2/environment/team/scenario/source_raw/humaneval_row.json": "077fe47c1c49ee61b2983cd423793a5fb737bcf421bfacdf8975d75858c142ec", - "tasks/ci-sharing-n-triangle-area-test-s2/environment/team/task.json": "c09757a368d5acb705ab2082da0f834a8dcb146dfad52ba3cf85a8c74b2329bf", + "tasks/ci-sharing-n-triangle-area-test-s2/environment/team/task.json": "499f12184dfccf1a55038dc147c76c71ddf70d8f5b5e44c9612d0288d1fb0aaa", "tasks/ci-sharing-n-triangle-area-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-sharing-n-triangle-area-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-sharing-n-triangle-area-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -6718,13 +6722,13 @@ "tasks/ci-sharing-n-triangle-area-test-s2/solution/policy.json": "ea674111870ed8f9124f6057fdcfba16302c0e8740e14a322e71ac16946d9dea", "tasks/ci-sharing-n-triangle-area-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-n-triangle-area-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-n-triangle-area-test-s2/task.toml": "02bc674bf8bef6489b33f657a8ca46e276474ef2d4be4673f88afb7b65181477", + "tasks/ci-sharing-n-triangle-area-test-s2/task.toml": "03ac5489e645625e35416ecba458538009cec19cc7977f44928a76f9c9cf52e9", "tasks/ci-sharing-n-triangle-area-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-n-triangle-area-test-s2/tests/expected.json": "39aa223016731f49497250026024ecb22ef10ebbcfcf0758e65454167f08195e", "tasks/ci-sharing-n-triangle-area-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-n-triangle-area-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-n-triangle-area-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-n-triangle-area-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-n-triangle-area-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-n-triangle-area-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-n-triangle-area-test-s2/tests/scenario/episode.yaml": "71f2a6fb0d550baa6eec320e96f8313488820404e4875b2a2775871a4a16e0bb", "tasks/ci-sharing-n-triangle-area-test-s2/tests/scenario/notes.md": "7bd1afd0a0ec693abb829e271076f9823d7532c1ea4d1047f9afc771b47b13d2", "tasks/ci-sharing-n-triangle-area-test-s2/tests/scenario/record.json": "780ee0d360bc395c32a17c1458e2f930848773e5456dc55de0e0823af42cf28d", @@ -6744,32 +6748,32 @@ "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/docker-compose.yaml": "3bfb5a318423c6734d22a21767894a83bb32b3d527056807e69a1c7b2c9518a2", - "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/team/scenario/episode.yaml": "4f56e051ea58378e91b81da1b03579e37c09c3351b38264a292a8c557fbb9d56", "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/team/scenario/notes.md": "8b3b47eeba061f6c587e879b4221137aa048e6aa2a97ee721464a79c4c734ff2", "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/team/scenario/raw_excerpt.txt": "76336abbcca31a59ffab12b4b7ceab7f461acea9358d97b2802183cac85fbcb3", "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/team/scenario/record.json": "a7e731df4ba6913b1948e1165f445e5dd51e784b1a7ac3c2964328f7ed3e88da", "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/team/scenario/source.md": "ea8cb57b7f3f3359ade31d43910c2da1a7371f25772208f48ea0e6d114f891b7", - "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/team/task.json": "27231c5d28b275c1b15dec054eadcae09624c833989e7fb5e279b446e7b53011", + "tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/team/task.json": "371716714091e232c54b9742149a9d446cd0c6d64c68a604c88468470f96dd83", "tasks/ci-sharing-r-beaded-lizards-solo-s0/instruction.md": "96938b3c7c72ca5a70ce30ca492d0bf8c39cab6ae4a9b8ed07b340fa46118a3f", "tasks/ci-sharing-r-beaded-lizards-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-beaded-lizards-solo-s0/solution/policy.json": "3f70e78b0269505a8fe35e41e1ca9eb3d19caf78df55b28667160873811f5123", "tasks/ci-sharing-r-beaded-lizards-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-beaded-lizards-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-beaded-lizards-solo-s0/task.toml": "35abeae092ef97b377745da7e62886dba9f2a2789a640d3765264ebbc8585fe0", + "tasks/ci-sharing-r-beaded-lizards-solo-s0/task.toml": "e25576ae8d7ccaafd3466f18a7cfc3ccccac2d126952d151d79be9b28d0639f1", "tasks/ci-sharing-r-beaded-lizards-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-beaded-lizards-solo-s0/tests/expected.json": "34dd88401b61eb607a9b8dd6b8db719dc328322ccb2431929aab4227f9c2b248", "tasks/ci-sharing-r-beaded-lizards-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-beaded-lizards-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-beaded-lizards-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-beaded-lizards-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-beaded-lizards-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-beaded-lizards-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-beaded-lizards-solo-s0/tests/scenario/episode.yaml": "4f56e051ea58378e91b81da1b03579e37c09c3351b38264a292a8c557fbb9d56", "tasks/ci-sharing-r-beaded-lizards-solo-s0/tests/scenario/notes.md": "8b3b47eeba061f6c587e879b4221137aa048e6aa2a97ee721464a79c4c734ff2", "tasks/ci-sharing-r-beaded-lizards-solo-s0/tests/scenario/raw_excerpt.txt": "76336abbcca31a59ffab12b4b7ceab7f461acea9358d97b2802183cac85fbcb3", @@ -6789,32 +6793,32 @@ "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/docker-compose.yaml": "fc35b301b8d98337c140b9bae7c1d3212fc0d63c6f70d6029bf17c2201dbf737", - "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/team/scenario/episode.yaml": "4f56e051ea58378e91b81da1b03579e37c09c3351b38264a292a8c557fbb9d56", "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/team/scenario/notes.md": "8b3b47eeba061f6c587e879b4221137aa048e6aa2a97ee721464a79c4c734ff2", "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/team/scenario/raw_excerpt.txt": "76336abbcca31a59ffab12b4b7ceab7f461acea9358d97b2802183cac85fbcb3", "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/team/scenario/record.json": "a7e731df4ba6913b1948e1165f445e5dd51e784b1a7ac3c2964328f7ed3e88da", "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/team/scenario/source.md": "ea8cb57b7f3f3359ade31d43910c2da1a7371f25772208f48ea0e6d114f891b7", - "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/team/task.json": "5c727cee97b9adf890d32d18ac01cff278e01db33e0d9bd7a4cff8f430ec48f7", + "tasks/ci-sharing-r-beaded-lizards-test-s0/environment/team/task.json": "fa416455694ca0341146aaa0110445be553e679192b77b50da990b5597d3f6ab", "tasks/ci-sharing-r-beaded-lizards-test-s0/instruction.md": "0ef93c1bf007ec1ec3f66bad3fa2495813d97bfa5338d092cee7267bb685afeb", "tasks/ci-sharing-r-beaded-lizards-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-beaded-lizards-test-s0/solution/policy.json": "3f70e78b0269505a8fe35e41e1ca9eb3d19caf78df55b28667160873811f5123", "tasks/ci-sharing-r-beaded-lizards-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-beaded-lizards-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-beaded-lizards-test-s0/task.toml": "2da89c9df17921a486349238664332bdb80bc61ce39abbb1b1a4a779baa43f30", + "tasks/ci-sharing-r-beaded-lizards-test-s0/task.toml": "9101eeb89f0f524cb6a7336a995f3f6a573659fcba5a3996da9773235c518667", "tasks/ci-sharing-r-beaded-lizards-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-beaded-lizards-test-s0/tests/expected.json": "7edeb68a0672c1a4bb0ab5175163b675f5a06fc258a6a8315f50c75d782a313b", "tasks/ci-sharing-r-beaded-lizards-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-beaded-lizards-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-beaded-lizards-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-beaded-lizards-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-beaded-lizards-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-beaded-lizards-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-beaded-lizards-test-s0/tests/scenario/episode.yaml": "4f56e051ea58378e91b81da1b03579e37c09c3351b38264a292a8c557fbb9d56", "tasks/ci-sharing-r-beaded-lizards-test-s0/tests/scenario/notes.md": "8b3b47eeba061f6c587e879b4221137aa048e6aa2a97ee721464a79c4c734ff2", "tasks/ci-sharing-r-beaded-lizards-test-s0/tests/scenario/raw_excerpt.txt": "76336abbcca31a59ffab12b4b7ceab7f461acea9358d97b2802183cac85fbcb3", @@ -6834,32 +6838,32 @@ "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/docker-compose.yaml": "2e645f6ffc519ce0bd4692ae4c97bead2459f6525f17392832341ec653983468", - "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/team/scenario/episode.yaml": "4f56e051ea58378e91b81da1b03579e37c09c3351b38264a292a8c557fbb9d56", "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/team/scenario/notes.md": "8b3b47eeba061f6c587e879b4221137aa048e6aa2a97ee721464a79c4c734ff2", "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/team/scenario/raw_excerpt.txt": "76336abbcca31a59ffab12b4b7ceab7f461acea9358d97b2802183cac85fbcb3", "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/team/scenario/record.json": "a7e731df4ba6913b1948e1165f445e5dd51e784b1a7ac3c2964328f7ed3e88da", "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/team/scenario/source.md": "ea8cb57b7f3f3359ade31d43910c2da1a7371f25772208f48ea0e6d114f891b7", - "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/team/task.json": "46f54b95efdd76b8e0a057e39089b28bed6fdaaad5a3e9a951e643afddcfb624", + "tasks/ci-sharing-r-beaded-lizards-test-s1/environment/team/task.json": "a4fbde162479f7ddbe25a108c4d177789bc0f2bd42b9253e9ad7202d5a2acb44", "tasks/ci-sharing-r-beaded-lizards-test-s1/instruction.md": "0ef93c1bf007ec1ec3f66bad3fa2495813d97bfa5338d092cee7267bb685afeb", "tasks/ci-sharing-r-beaded-lizards-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-beaded-lizards-test-s1/solution/policy.json": "3f70e78b0269505a8fe35e41e1ca9eb3d19caf78df55b28667160873811f5123", "tasks/ci-sharing-r-beaded-lizards-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-beaded-lizards-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-beaded-lizards-test-s1/task.toml": "e581384cd225a7a6ffd65ca5bdf79387fdcfd39f4a1d9fde58b1c9a529756b47", + "tasks/ci-sharing-r-beaded-lizards-test-s1/task.toml": "1c5225a88c95eb36db04710e1605418d0a41e8ff479cbbd1a198358448b5a13b", "tasks/ci-sharing-r-beaded-lizards-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-beaded-lizards-test-s1/tests/expected.json": "bcba1d43e488cc87ee8b7869cf49e5f8f6829c4ddfacd5268ff2505951a36e6f", "tasks/ci-sharing-r-beaded-lizards-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-beaded-lizards-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-beaded-lizards-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-beaded-lizards-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-beaded-lizards-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-beaded-lizards-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-beaded-lizards-test-s1/tests/scenario/episode.yaml": "4f56e051ea58378e91b81da1b03579e37c09c3351b38264a292a8c557fbb9d56", "tasks/ci-sharing-r-beaded-lizards-test-s1/tests/scenario/notes.md": "8b3b47eeba061f6c587e879b4221137aa048e6aa2a97ee721464a79c4c734ff2", "tasks/ci-sharing-r-beaded-lizards-test-s1/tests/scenario/raw_excerpt.txt": "76336abbcca31a59ffab12b4b7ceab7f461acea9358d97b2802183cac85fbcb3", @@ -6879,32 +6883,32 @@ "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/docker-compose.yaml": "dd88a7e5996340aa4fa574fb9791b251e58199b15c8ad342886c9d15e15987f9", - "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/team/scenario/episode.yaml": "4f56e051ea58378e91b81da1b03579e37c09c3351b38264a292a8c557fbb9d56", "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/team/scenario/notes.md": "8b3b47eeba061f6c587e879b4221137aa048e6aa2a97ee721464a79c4c734ff2", "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/team/scenario/raw_excerpt.txt": "76336abbcca31a59ffab12b4b7ceab7f461acea9358d97b2802183cac85fbcb3", "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/team/scenario/record.json": "a7e731df4ba6913b1948e1165f445e5dd51e784b1a7ac3c2964328f7ed3e88da", "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/team/scenario/source.md": "ea8cb57b7f3f3359ade31d43910c2da1a7371f25772208f48ea0e6d114f891b7", - "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/team/task.json": "6a7b5da453491d5ef0304cb3030618282731082188ab5a898cc71c326e20762f", + "tasks/ci-sharing-r-beaded-lizards-test-s2/environment/team/task.json": "859281bf2d8de162ab2d2748c83f701249684c6563e7a32cffb305992fd395ca", "tasks/ci-sharing-r-beaded-lizards-test-s2/instruction.md": "0ef93c1bf007ec1ec3f66bad3fa2495813d97bfa5338d092cee7267bb685afeb", "tasks/ci-sharing-r-beaded-lizards-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-beaded-lizards-test-s2/solution/policy.json": "3f70e78b0269505a8fe35e41e1ca9eb3d19caf78df55b28667160873811f5123", "tasks/ci-sharing-r-beaded-lizards-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-beaded-lizards-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-beaded-lizards-test-s2/task.toml": "e0ab13a0e37bc73cce92ce6c0747dd50fb562c4ef961bfee1a53762c60202af2", + "tasks/ci-sharing-r-beaded-lizards-test-s2/task.toml": "2ead027f7ea65c045ca2ac2f3bdf9303f240919db7beea38b214f59f3d8b0074", "tasks/ci-sharing-r-beaded-lizards-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-beaded-lizards-test-s2/tests/expected.json": "c6c208dbdde48a7429c8dc1088358ff721628564d16ef468099876ff1b1b7b54", "tasks/ci-sharing-r-beaded-lizards-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-beaded-lizards-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-beaded-lizards-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-beaded-lizards-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-beaded-lizards-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-beaded-lizards-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-beaded-lizards-test-s2/tests/scenario/episode.yaml": "4f56e051ea58378e91b81da1b03579e37c09c3351b38264a292a8c557fbb9d56", "tasks/ci-sharing-r-beaded-lizards-test-s2/tests/scenario/notes.md": "8b3b47eeba061f6c587e879b4221137aa048e6aa2a97ee721464a79c4c734ff2", "tasks/ci-sharing-r-beaded-lizards-test-s2/tests/scenario/raw_excerpt.txt": "76336abbcca31a59ffab12b4b7ceab7f461acea9358d97b2802183cac85fbcb3", @@ -6924,31 +6928,31 @@ "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/docker-compose.yaml": "8293b3957d533043d80b25cbf8290c6bed15403dac1eb656ef2ae48148fa6886", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/team/scenario/episode.yaml": "271882ed5b9d8e64b8bbb210209bd89b995de029b64440499d6aeb6c5ebdae5b", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/team/scenario/notes.md": "4194ea2a38e35b6a1270ff71bb69fa3a1a531d7dfbbce517872658b1bd1c58ab", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/team/scenario/record.json": "987ca7c7b5603a5f414f3e8d5dae8bef45d1894b5b285430eab8713dd42598f9", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/team/scenario/source.md": "73b9cdc23acd46d336628c852d2c5803b3507268810be0a7bb00b2688da58a65", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/team/task.json": "8fb9a24ad068bad149e1d2155c766f7726088503f4b00230ba5248cef7eb5342", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/team/task.json": "05afb127b041e3a3fbb869bb5fff0614ac58ab4e05b6504d880105845533e0e0", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/instruction.md": "569b2670c20cc740d2c85234a41d694735f3a66b6a6306fb1fddfd7024b2604c", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/solution/policy.json": "3411bcfc403258246553a277725a2f7200ab7fdee43c8840ff3156c07db465e2", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/task.toml": "215b69bdbc65554dc3b37fde5fa4d5fc181606b9ff9c9e0bfc77ecfdd3a9a8f1", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/task.toml": "e5105fb47275b1a288bfa04ce030bf7c4b9312efa2cca00879db1826e05afdc0", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/tests/expected.json": "6c2710d2507352f2fd93fe6c19c08364f20c52b1c6b354c71f0afc27f01920d2", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/tests/scenario/episode.yaml": "271882ed5b9d8e64b8bbb210209bd89b995de029b64440499d6aeb6c5ebdae5b", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/tests/scenario/notes.md": "4194ea2a38e35b6a1270ff71bb69fa3a1a531d7dfbbce517872658b1bd1c58ab", "tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/tests/scenario/record.json": "987ca7c7b5603a5f414f3e8d5dae8bef45d1894b5b285430eab8713dd42598f9", @@ -6967,31 +6971,31 @@ "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/docker-compose.yaml": "2c4d65a24955b0b344e6d5dc1e2f7105120a2f25fe79aabd8de6bef0dd6462c4", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/team/scenario/episode.yaml": "271882ed5b9d8e64b8bbb210209bd89b995de029b64440499d6aeb6c5ebdae5b", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/team/scenario/notes.md": "4194ea2a38e35b6a1270ff71bb69fa3a1a531d7dfbbce517872658b1bd1c58ab", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/team/scenario/record.json": "987ca7c7b5603a5f414f3e8d5dae8bef45d1894b5b285430eab8713dd42598f9", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/team/scenario/source.md": "73b9cdc23acd46d336628c852d2c5803b3507268810be0a7bb00b2688da58a65", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/team/task.json": "8f088d752c78ed7ff2d531c5d779a146ba438ac12800602a3429f6a7d8d56917", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/team/task.json": "74d2216982030a03eb9c93a7d299745f8a810cd4bba652c5355fd0042ecefb9c", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/instruction.md": "01ccd187828e115833f952b35a8225e9251e6b78550622449df245e027a8e1b3", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/solution/policy.json": "3411bcfc403258246553a277725a2f7200ab7fdee43c8840ff3156c07db465e2", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/task.toml": "727d7bc3caa29c024c16e65c039266999c4aef8dfd95ae03e2c2437e5c3b1fe0", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/task.toml": "cbf446673ac70ec3074a79bfba22076be63a73c5de5af86b92c71c2a7c5b0ffe", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/tests/expected.json": "82154ba3cdf55a26308e88882486375c3d646d99fb1e821f274c45596b0b5748", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/tests/scenario/episode.yaml": "271882ed5b9d8e64b8bbb210209bd89b995de029b64440499d6aeb6c5ebdae5b", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/tests/scenario/notes.md": "4194ea2a38e35b6a1270ff71bb69fa3a1a531d7dfbbce517872658b1bd1c58ab", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/tests/scenario/record.json": "987ca7c7b5603a5f414f3e8d5dae8bef45d1894b5b285430eab8713dd42598f9", @@ -7010,31 +7014,31 @@ "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/docker-compose.yaml": "2317319318cf418d20987fc5c9c7b4f01f57b5de26b0258c309edc4cb67934d7", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/team/scenario/episode.yaml": "271882ed5b9d8e64b8bbb210209bd89b995de029b64440499d6aeb6c5ebdae5b", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/team/scenario/notes.md": "4194ea2a38e35b6a1270ff71bb69fa3a1a531d7dfbbce517872658b1bd1c58ab", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/team/scenario/record.json": "987ca7c7b5603a5f414f3e8d5dae8bef45d1894b5b285430eab8713dd42598f9", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/team/scenario/source.md": "73b9cdc23acd46d336628c852d2c5803b3507268810be0a7bb00b2688da58a65", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/team/task.json": "8a1d6d99a7eb53bb5a3ecffd8ada918af8327d090952bba4cd972216d19fffc8", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/team/task.json": "8123d92d80c248d0542c9461d5348fa9fedfbed652ab71186cb24896114d0c95", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/instruction.md": "01ccd187828e115833f952b35a8225e9251e6b78550622449df245e027a8e1b3", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/solution/policy.json": "3411bcfc403258246553a277725a2f7200ab7fdee43c8840ff3156c07db465e2", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/task.toml": "01ea10887afefa2bbe519dd4a235964e386aa9358e617bb5f90d34026377ca50", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/task.toml": "b7fba0216548a7e138abd035deacc7d06292988d0cb10afc8950b099ecad9256", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/tests/expected.json": "9126f24c7442654775188a7c0480b993e2d4ad93e72e7f1316a7a726e102e4c2", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/tests/scenario/episode.yaml": "271882ed5b9d8e64b8bbb210209bd89b995de029b64440499d6aeb6c5ebdae5b", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/tests/scenario/notes.md": "4194ea2a38e35b6a1270ff71bb69fa3a1a531d7dfbbce517872658b1bd1c58ab", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/tests/scenario/record.json": "987ca7c7b5603a5f414f3e8d5dae8bef45d1894b5b285430eab8713dd42598f9", @@ -7053,31 +7057,31 @@ "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/docker-compose.yaml": "09151baa5b9abc89ffbb85bcda8dc4c2e3ee336c4abfab7f92dd656c9662641f", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/team/scenario/episode.yaml": "271882ed5b9d8e64b8bbb210209bd89b995de029b64440499d6aeb6c5ebdae5b", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/team/scenario/notes.md": "4194ea2a38e35b6a1270ff71bb69fa3a1a531d7dfbbce517872658b1bd1c58ab", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/team/scenario/record.json": "987ca7c7b5603a5f414f3e8d5dae8bef45d1894b5b285430eab8713dd42598f9", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/team/scenario/source.md": "73b9cdc23acd46d336628c852d2c5803b3507268810be0a7bb00b2688da58a65", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/team/task.json": "7dfeee3c7cd825cfc3defbb2210dd5c7ba89e36d5ea65d344d846111c7a16842", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/team/task.json": "860c05aa05c0b549f1c01d8c4903d201d86d82024ecd2f6988c6a34520a75e7e", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/instruction.md": "01ccd187828e115833f952b35a8225e9251e6b78550622449df245e027a8e1b3", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/solution/policy.json": "3411bcfc403258246553a277725a2f7200ab7fdee43c8840ff3156c07db465e2", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/task.toml": "7e3334d27d92a3ef56acb79bd280b8080378521b2e5cd8c29b11fef0667bb5ba", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/task.toml": "072db9e08ca14159729e9f042ee46f5df91b1981e655a8cdb797caf51f9570de", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/tests/expected.json": "cd81bb372344f23875f38c8f62ffd5ebf6a7d7d951e297ca09cecb867ea1f968", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/tests/scenario/episode.yaml": "271882ed5b9d8e64b8bbb210209bd89b995de029b64440499d6aeb6c5ebdae5b", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/tests/scenario/notes.md": "4194ea2a38e35b6a1270ff71bb69fa3a1a531d7dfbbce517872658b1bd1c58ab", "tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/tests/scenario/record.json": "987ca7c7b5603a5f414f3e8d5dae8bef45d1894b5b285430eab8713dd42598f9", @@ -7096,31 +7100,31 @@ "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/docker-compose.yaml": "db759423f3dfff294bbff8a5ce150a89fbfa3d972133b66d1ae94546d51927ac", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/team/scenario/episode.yaml": "f9ade42737fba5ba1e1e17aec8fb1003ae1f122398eaa57b52636e0de045c4ed", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/team/scenario/notes.md": "6bad16c6dfb342b097c1c48205294777c652d93a159a5f8170782503b2dc73cd", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/team/scenario/record.json": "393374d42b552dbb26c64032763f8d986d6529e7b8eeb9757d55dbbc4d70014b", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/team/scenario/source.md": "21fe900a25fb916bd15d138554aaaaa526fd150a4db4389a4b5ad9da5bc2695d", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/team/task.json": "105a5576300c8cf62016327f0345af4744334ff8129c4b713ea2bad436e2cfbd", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/team/task.json": "174a0551841b2049b15eb4d16361aa25e98db4f2ee29f9222d61d2930440ea77", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/instruction.md": "791eef704dcbdc30dde017b8b6d8c83cdf83354b4286e09e214d7d148c1a0de9", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/solution/policy.json": "598e12438d5a37e11fd56180b4a72ce2eaa00acc8b8696bc99e5ef94116f2256", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/task.toml": "0640fd6520adc37784155e7134581a315f462bbbff2651f64c30f550b12e1822", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/task.toml": "776a05c488dd14fe013e82f776355bf558fa75e9a24f50448e95ddbb66d103ce", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/tests/expected.json": "00fb9af817fd006dfa34d5d9cd68ee8981d5e06cdffd9f16d70095343fa99489", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/tests/scenario/episode.yaml": "f9ade42737fba5ba1e1e17aec8fb1003ae1f122398eaa57b52636e0de045c4ed", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/tests/scenario/notes.md": "6bad16c6dfb342b097c1c48205294777c652d93a159a5f8170782503b2dc73cd", "tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/tests/scenario/record.json": "393374d42b552dbb26c64032763f8d986d6529e7b8eeb9757d55dbbc4d70014b", @@ -7139,31 +7143,31 @@ "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/docker-compose.yaml": "44b464e75a190836623cdf4ca4f61be4cffe1d80182b3a9324981b6eb0a86a43", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/team/scenario/episode.yaml": "f9ade42737fba5ba1e1e17aec8fb1003ae1f122398eaa57b52636e0de045c4ed", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/team/scenario/notes.md": "6bad16c6dfb342b097c1c48205294777c652d93a159a5f8170782503b2dc73cd", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/team/scenario/record.json": "393374d42b552dbb26c64032763f8d986d6529e7b8eeb9757d55dbbc4d70014b", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/team/scenario/source.md": "21fe900a25fb916bd15d138554aaaaa526fd150a4db4389a4b5ad9da5bc2695d", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/team/task.json": "710b614efd714b21de3869cfdefc0d2a7355c7f62c7646a77ea178dde6da4a08", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/team/task.json": "95b8967feffc8fc2ab86cc246edad6a7d51b0d6ac69b86ef2bf65b1d6a7540b3", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/instruction.md": "ea9dc4d4cb61f5d775cb26ad52c2a1da918d8463e785ad73e882f340eb6cd93d", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/solution/policy.json": "598e12438d5a37e11fd56180b4a72ce2eaa00acc8b8696bc99e5ef94116f2256", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/task.toml": "8baac7eddda91bd842f77448b0992bd4e91c824221a1c5b66b2a2408d8077866", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/task.toml": "69c960db9ec40cfa35d454113c36ab152a94ff80f147fac30ff8a512831674e6", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/tests/expected.json": "d3f366fb298363dcd6299a0f74fa5cc833ab08c7a5996d4caa3f4acb03d6f2bc", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/tests/scenario/episode.yaml": "f9ade42737fba5ba1e1e17aec8fb1003ae1f122398eaa57b52636e0de045c4ed", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/tests/scenario/notes.md": "6bad16c6dfb342b097c1c48205294777c652d93a159a5f8170782503b2dc73cd", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/tests/scenario/record.json": "393374d42b552dbb26c64032763f8d986d6529e7b8eeb9757d55dbbc4d70014b", @@ -7182,31 +7186,31 @@ "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/docker-compose.yaml": "50267f3a25fbd13cb22992f861b4bc7647cb841ff4e1e12b27b21b1c404d8912", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/team/scenario/episode.yaml": "f9ade42737fba5ba1e1e17aec8fb1003ae1f122398eaa57b52636e0de045c4ed", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/team/scenario/notes.md": "6bad16c6dfb342b097c1c48205294777c652d93a159a5f8170782503b2dc73cd", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/team/scenario/record.json": "393374d42b552dbb26c64032763f8d986d6529e7b8eeb9757d55dbbc4d70014b", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/team/scenario/source.md": "21fe900a25fb916bd15d138554aaaaa526fd150a4db4389a4b5ad9da5bc2695d", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/team/task.json": "67db55a1b6aa13606e34849d40f9da6a4126ba5697a029e17f2cf97b1d342568", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/team/task.json": "4cf52bebb19bf4d3e855065f14214a174afb77565dc4abfe92bf0ea60409bcab", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/instruction.md": "ea9dc4d4cb61f5d775cb26ad52c2a1da918d8463e785ad73e882f340eb6cd93d", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/solution/policy.json": "598e12438d5a37e11fd56180b4a72ce2eaa00acc8b8696bc99e5ef94116f2256", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/task.toml": "d9458d6a7e177b50803c4798448a499963a1bf50bc13cc7caa276e5b94c384ec", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/task.toml": "c940a10df4a4d973a313d6e1422f4260d374f2d320cd4a0b0f7ee6045944dea9", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/tests/expected.json": "e9d240a8dd0348d5670bd0c0d61ba7fe92bc4fafbbf15ba96f5b05b957b1e442", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/tests/scenario/episode.yaml": "f9ade42737fba5ba1e1e17aec8fb1003ae1f122398eaa57b52636e0de045c4ed", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/tests/scenario/notes.md": "6bad16c6dfb342b097c1c48205294777c652d93a159a5f8170782503b2dc73cd", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/tests/scenario/record.json": "393374d42b552dbb26c64032763f8d986d6529e7b8eeb9757d55dbbc4d70014b", @@ -7225,31 +7229,31 @@ "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/docker-compose.yaml": "90cb52da3d3bb084c30271bfb78bf7a967d5d955794f6db9d41976144fa92396", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/team/scenario/episode.yaml": "f9ade42737fba5ba1e1e17aec8fb1003ae1f122398eaa57b52636e0de045c4ed", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/team/scenario/notes.md": "6bad16c6dfb342b097c1c48205294777c652d93a159a5f8170782503b2dc73cd", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/team/scenario/record.json": "393374d42b552dbb26c64032763f8d986d6529e7b8eeb9757d55dbbc4d70014b", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/team/scenario/source.md": "21fe900a25fb916bd15d138554aaaaa526fd150a4db4389a4b5ad9da5bc2695d", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/team/task.json": "4311d788e44cd4a02bcde78f7c4171e9a93d3566049a220aecfec18c53067ba5", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/team/task.json": "98fd4495af9524976704c10d3247d4e29c4e6ed7de593432270901bd4c3b9e51", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/instruction.md": "ea9dc4d4cb61f5d775cb26ad52c2a1da918d8463e785ad73e882f340eb6cd93d", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/solution/policy.json": "598e12438d5a37e11fd56180b4a72ce2eaa00acc8b8696bc99e5ef94116f2256", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/task.toml": "217b89596c0c2b8ca66c50daa863f1f3ce5bf7b391c0552ad9efe89799e1f246", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/task.toml": "aec41f306eb39c7871278844ab78b3daa4794a454d19b89e123ce0d01a4d9bdf", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/tests/expected.json": "a1077ed215e4c1c9befe161d48f3fb5a5aad91542434733f52385ca0cd89ca41", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/tests/scenario/episode.yaml": "f9ade42737fba5ba1e1e17aec8fb1003ae1f122398eaa57b52636e0de045c4ed", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/tests/scenario/notes.md": "6bad16c6dfb342b097c1c48205294777c652d93a159a5f8170782503b2dc73cd", "tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/tests/scenario/record.json": "393374d42b552dbb26c64032763f8d986d6529e7b8eeb9757d55dbbc4d70014b", @@ -7268,32 +7272,32 @@ "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/docker-compose.yaml": "2be6d35d72e46e45433bfc8101f4c30e99375d18dd23a0885025cd31dc61f7bd", - "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/team/scenario/episode.yaml": "c2cf41748f81b8be3695ef5b9523c9f1134ca3d6314d5e7e6119a050c6f762b4", "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/team/scenario/notes.md": "f562f8f87aa74b321d584e8c25422f158530a3623d3e13c13acfe9b7ddf86f2a", "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/team/scenario/raw_excerpt.txt": "caddf0342299d45f524d3927859d73dc7687786bee95920b1612bb273387837e", "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/team/scenario/record.json": "58a325de31f4862d97e2867ba3a53d15d8d598f23c1d6ac41218224ade5cc2b6", "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/team/scenario/source.md": "f89171c9bb801406040efc53c68c0392db42874a75935e6d5c6c3ede08ac8a9f", - "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/team/task.json": "9fa8a60d50cc0827ab73ca671fd9efab569e57c803b4b48de30b456ff8792be5", + "tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/team/task.json": "d8dd852952cf753748c726bc32ca02a6e45d7159cd409b24aa8bd66101316435", "tasks/ci-sharing-r-emperor-regiment-solo-s0/instruction.md": "d24efc02d601fd47cd2ecd0e8d6dba322fa07cf04ab2ad5b9e762448537a2115", "tasks/ci-sharing-r-emperor-regiment-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-emperor-regiment-solo-s0/solution/policy.json": "4311ec1047bd009c9bb8a59f40730fb27ac0a604f423982d084e30a9cf8b6eeb", "tasks/ci-sharing-r-emperor-regiment-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-emperor-regiment-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-emperor-regiment-solo-s0/task.toml": "df01ff27c942cf869b7f2954b1b61124203607b0b74efccca7224111bf32647b", + "tasks/ci-sharing-r-emperor-regiment-solo-s0/task.toml": "1e80845161bb0f5bbd3f1efd8a186a8f662ae503174e87f4220d235fa5b562da", "tasks/ci-sharing-r-emperor-regiment-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-emperor-regiment-solo-s0/tests/expected.json": "be9c7b66110415716140f5cc8056c1b98804a8366acd05ce2b090f9c129fede0", "tasks/ci-sharing-r-emperor-regiment-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emperor-regiment-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emperor-regiment-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emperor-regiment-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emperor-regiment-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emperor-regiment-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emperor-regiment-solo-s0/tests/scenario/episode.yaml": "c2cf41748f81b8be3695ef5b9523c9f1134ca3d6314d5e7e6119a050c6f762b4", "tasks/ci-sharing-r-emperor-regiment-solo-s0/tests/scenario/notes.md": "f562f8f87aa74b321d584e8c25422f158530a3623d3e13c13acfe9b7ddf86f2a", "tasks/ci-sharing-r-emperor-regiment-solo-s0/tests/scenario/raw_excerpt.txt": "caddf0342299d45f524d3927859d73dc7687786bee95920b1612bb273387837e", @@ -7313,32 +7317,32 @@ "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/docker-compose.yaml": "7edfe2539d38b4d225759377e7bf7bb322ba5ca9288c2e5ee1583c04567f75e0", - "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/team/scenario/episode.yaml": "c2cf41748f81b8be3695ef5b9523c9f1134ca3d6314d5e7e6119a050c6f762b4", "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/team/scenario/notes.md": "f562f8f87aa74b321d584e8c25422f158530a3623d3e13c13acfe9b7ddf86f2a", "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/team/scenario/raw_excerpt.txt": "caddf0342299d45f524d3927859d73dc7687786bee95920b1612bb273387837e", "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/team/scenario/record.json": "58a325de31f4862d97e2867ba3a53d15d8d598f23c1d6ac41218224ade5cc2b6", "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/team/scenario/source.md": "f89171c9bb801406040efc53c68c0392db42874a75935e6d5c6c3ede08ac8a9f", - "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/team/task.json": "843c1a42d7ec542d342b53d5edde26a8bfd845a3ee4ee18ddba2d7ae9bd9ba7c", + "tasks/ci-sharing-r-emperor-regiment-test-s0/environment/team/task.json": "ba6e71535a37ccf7ba446e596dee210d91c71b0946709b2e3438d0afdb755bb0", "tasks/ci-sharing-r-emperor-regiment-test-s0/instruction.md": "3a8c42dd7c69f6e2ea575d780a9954e0927b76a1693cfecf68f7498c27cb3e03", "tasks/ci-sharing-r-emperor-regiment-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-emperor-regiment-test-s0/solution/policy.json": "c9be293be041acb40a40694af9314d97cc4565c0a46dfb271160f81ac7372c5c", "tasks/ci-sharing-r-emperor-regiment-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-emperor-regiment-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-emperor-regiment-test-s0/task.toml": "862b3e2fa4da1eb3dfad3f3cd75b5e575b2f1991ee49b63869895f58b40f43f3", + "tasks/ci-sharing-r-emperor-regiment-test-s0/task.toml": "af23eea09d61e498be673c88d17170b766554b6523a47be25f98541bc52eed06", "tasks/ci-sharing-r-emperor-regiment-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-emperor-regiment-test-s0/tests/expected.json": "574c8ae519ca9bd9a079f5c38a22ef95aa54fb5184ba0e06ae42eede3f1986df", "tasks/ci-sharing-r-emperor-regiment-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emperor-regiment-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emperor-regiment-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emperor-regiment-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emperor-regiment-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emperor-regiment-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emperor-regiment-test-s0/tests/scenario/episode.yaml": "c2cf41748f81b8be3695ef5b9523c9f1134ca3d6314d5e7e6119a050c6f762b4", "tasks/ci-sharing-r-emperor-regiment-test-s0/tests/scenario/notes.md": "f562f8f87aa74b321d584e8c25422f158530a3623d3e13c13acfe9b7ddf86f2a", "tasks/ci-sharing-r-emperor-regiment-test-s0/tests/scenario/raw_excerpt.txt": "caddf0342299d45f524d3927859d73dc7687786bee95920b1612bb273387837e", @@ -7358,32 +7362,32 @@ "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/docker-compose.yaml": "21d3122edeed95b8cfe1eff38edb357550c1787599987d304159706c9fe68ce6", - "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/team/scenario/episode.yaml": "c2cf41748f81b8be3695ef5b9523c9f1134ca3d6314d5e7e6119a050c6f762b4", "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/team/scenario/notes.md": "f562f8f87aa74b321d584e8c25422f158530a3623d3e13c13acfe9b7ddf86f2a", "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/team/scenario/raw_excerpt.txt": "caddf0342299d45f524d3927859d73dc7687786bee95920b1612bb273387837e", "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/team/scenario/record.json": "58a325de31f4862d97e2867ba3a53d15d8d598f23c1d6ac41218224ade5cc2b6", "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/team/scenario/source.md": "f89171c9bb801406040efc53c68c0392db42874a75935e6d5c6c3ede08ac8a9f", - "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/team/task.json": "d62a464d748bf35daa391120c5fbb53bee67c1de1f2b059731f7ca39014c2ea8", + "tasks/ci-sharing-r-emperor-regiment-test-s1/environment/team/task.json": "86b1ebe6f49b73c9adea509b129fe7054cf868ce116898e75a255aa0f7227fab", "tasks/ci-sharing-r-emperor-regiment-test-s1/instruction.md": "3a8c42dd7c69f6e2ea575d780a9954e0927b76a1693cfecf68f7498c27cb3e03", "tasks/ci-sharing-r-emperor-regiment-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-emperor-regiment-test-s1/solution/policy.json": "c9be293be041acb40a40694af9314d97cc4565c0a46dfb271160f81ac7372c5c", "tasks/ci-sharing-r-emperor-regiment-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-emperor-regiment-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-emperor-regiment-test-s1/task.toml": "37665ae5ee53926ce66f5911a2a9c8e8f599cd864a2b5287c7f1e5432199736b", + "tasks/ci-sharing-r-emperor-regiment-test-s1/task.toml": "e4ec90e310ad53e5f8a6b7b16f24dba9043ee3b9016b15d4cd8d18d8932ff57f", "tasks/ci-sharing-r-emperor-regiment-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-emperor-regiment-test-s1/tests/expected.json": "539ee10039ba67f1fc3372cfd8ba8a2e645a8b864a0bae630036d9d046a97233", "tasks/ci-sharing-r-emperor-regiment-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emperor-regiment-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emperor-regiment-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emperor-regiment-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emperor-regiment-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emperor-regiment-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emperor-regiment-test-s1/tests/scenario/episode.yaml": "c2cf41748f81b8be3695ef5b9523c9f1134ca3d6314d5e7e6119a050c6f762b4", "tasks/ci-sharing-r-emperor-regiment-test-s1/tests/scenario/notes.md": "f562f8f87aa74b321d584e8c25422f158530a3623d3e13c13acfe9b7ddf86f2a", "tasks/ci-sharing-r-emperor-regiment-test-s1/tests/scenario/raw_excerpt.txt": "caddf0342299d45f524d3927859d73dc7687786bee95920b1612bb273387837e", @@ -7403,32 +7407,32 @@ "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/docker-compose.yaml": "2e95981671cf3e5b147be1f8b0ac05dc09c0787dbcc9f5617cb295a9012113c2", - "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/team/scenario/episode.yaml": "c2cf41748f81b8be3695ef5b9523c9f1134ca3d6314d5e7e6119a050c6f762b4", "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/team/scenario/notes.md": "f562f8f87aa74b321d584e8c25422f158530a3623d3e13c13acfe9b7ddf86f2a", "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/team/scenario/raw_excerpt.txt": "caddf0342299d45f524d3927859d73dc7687786bee95920b1612bb273387837e", "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/team/scenario/record.json": "58a325de31f4862d97e2867ba3a53d15d8d598f23c1d6ac41218224ade5cc2b6", "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/team/scenario/source.md": "f89171c9bb801406040efc53c68c0392db42874a75935e6d5c6c3ede08ac8a9f", - "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/team/task.json": "fcfd19a1c001b2bc84274bd3e84c41205ea2aaf76952066f696cf01140995903", + "tasks/ci-sharing-r-emperor-regiment-test-s2/environment/team/task.json": "2c98aab86cd6dbb416ea5445ec4d07715e8e9bf783562b813f3f9ab084afb1b0", "tasks/ci-sharing-r-emperor-regiment-test-s2/instruction.md": "3a8c42dd7c69f6e2ea575d780a9954e0927b76a1693cfecf68f7498c27cb3e03", "tasks/ci-sharing-r-emperor-regiment-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-emperor-regiment-test-s2/solution/policy.json": "c9be293be041acb40a40694af9314d97cc4565c0a46dfb271160f81ac7372c5c", "tasks/ci-sharing-r-emperor-regiment-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-emperor-regiment-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-emperor-regiment-test-s2/task.toml": "2be929fb35b600ba2be523d594b0aa61e74d941d6e0d62ca19add4b5b119b419", + "tasks/ci-sharing-r-emperor-regiment-test-s2/task.toml": "419f96c6fb43ca70332094754456e66e3bff4b13b3da3cd2b7fd7c5d458ee274", "tasks/ci-sharing-r-emperor-regiment-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-emperor-regiment-test-s2/tests/expected.json": "f63ba28c5db99c7b5c84b4b6e595efd2a59be7631ab5dfe806b8c550a99793ac", "tasks/ci-sharing-r-emperor-regiment-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-emperor-regiment-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-emperor-regiment-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-emperor-regiment-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-emperor-regiment-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-emperor-regiment-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-emperor-regiment-test-s2/tests/scenario/episode.yaml": "c2cf41748f81b8be3695ef5b9523c9f1134ca3d6314d5e7e6119a050c6f762b4", "tasks/ci-sharing-r-emperor-regiment-test-s2/tests/scenario/notes.md": "f562f8f87aa74b321d584e8c25422f158530a3623d3e13c13acfe9b7ddf86f2a", "tasks/ci-sharing-r-emperor-regiment-test-s2/tests/scenario/raw_excerpt.txt": "caddf0342299d45f524d3927859d73dc7687786bee95920b1612bb273387837e", @@ -7448,32 +7452,32 @@ "tasks/ci-sharing-r-field-trip-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-field-trip-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-field-trip-solo-s0/environment/docker-compose.yaml": "46179f090a6f6f75df16b3a0deb29cf6b819ab38a04ac138985f02a97ee2d437", - "tasks/ci-sharing-r-field-trip-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-field-trip-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-field-trip-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-field-trip-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-field-trip-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-field-trip-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-field-trip-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-field-trip-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-field-trip-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-field-trip-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-field-trip-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-field-trip-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-field-trip-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-field-trip-solo-s0/environment/team/scenario/episode.yaml": "1c03810dcbdcbe513d2da954d0aa89a1b3aa7205e0f6d87c809bfc08e04ec7c4", "tasks/ci-sharing-r-field-trip-solo-s0/environment/team/scenario/notes.md": "ee5fd3b77bf18432325bb4d74e70f262c036ede162e5358cbf46a89e608c7fe1", "tasks/ci-sharing-r-field-trip-solo-s0/environment/team/scenario/raw_excerpt.txt": "655626d175e3b1bac0052fd24a6329d9ff8ecc1120d8ee8ddbe40df4ad033a28", "tasks/ci-sharing-r-field-trip-solo-s0/environment/team/scenario/record.json": "4741c0dcd8eb002f2225d302fe7603e7a8352f631f396e5b4de2a7f1edeb71ed", "tasks/ci-sharing-r-field-trip-solo-s0/environment/team/scenario/source.md": "8e54e3637b410741a05fc79a9c261530bfebb29bdec0bcdc8f9b326800e8ab5b", - "tasks/ci-sharing-r-field-trip-solo-s0/environment/team/task.json": "6ce057de4c0c375f3394781219d4dcb4d7818e460c75807b6399dd45777fbd79", + "tasks/ci-sharing-r-field-trip-solo-s0/environment/team/task.json": "bc240f671b33425e2c9b371b06da803c8ef096d4ccc08351450536b581d79b57", "tasks/ci-sharing-r-field-trip-solo-s0/instruction.md": "8a1364f1a3a509fe8bed2b7ed812e73f67cb38e827b4505bd05647547cdc5710", "tasks/ci-sharing-r-field-trip-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-field-trip-solo-s0/solution/policy.json": "61debc9cdd4217305848faa12193a874cc990995403e4232e50882e43000e7fe", "tasks/ci-sharing-r-field-trip-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-field-trip-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-field-trip-solo-s0/task.toml": "1372bd98254acbb7d65fd56efbc68590e45d08eb768fc0b361a79fb88d367d85", + "tasks/ci-sharing-r-field-trip-solo-s0/task.toml": "78f2075df07b1c3c829d206862bb4aa44e3be00711d312658eff95ae49f159bf", "tasks/ci-sharing-r-field-trip-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-field-trip-solo-s0/tests/expected.json": "fabccd5b24427b71a955d755f2f4da20086d6ec113218dbeb07c17a44d23a2a2", "tasks/ci-sharing-r-field-trip-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-field-trip-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-field-trip-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-field-trip-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-field-trip-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-field-trip-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-field-trip-solo-s0/tests/scenario/episode.yaml": "1c03810dcbdcbe513d2da954d0aa89a1b3aa7205e0f6d87c809bfc08e04ec7c4", "tasks/ci-sharing-r-field-trip-solo-s0/tests/scenario/notes.md": "ee5fd3b77bf18432325bb4d74e70f262c036ede162e5358cbf46a89e608c7fe1", "tasks/ci-sharing-r-field-trip-solo-s0/tests/scenario/raw_excerpt.txt": "655626d175e3b1bac0052fd24a6329d9ff8ecc1120d8ee8ddbe40df4ad033a28", @@ -7493,32 +7497,32 @@ "tasks/ci-sharing-r-field-trip-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-field-trip-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-field-trip-test-s0/environment/docker-compose.yaml": "973f301b74baa7c572c1d3a271c89e909cb506ec3faf396eee9e8f5af9acc76f", - "tasks/ci-sharing-r-field-trip-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-field-trip-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-field-trip-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-field-trip-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-field-trip-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-field-trip-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-field-trip-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-field-trip-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-field-trip-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-field-trip-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-field-trip-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-field-trip-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-field-trip-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-field-trip-test-s0/environment/team/scenario/episode.yaml": "1c03810dcbdcbe513d2da954d0aa89a1b3aa7205e0f6d87c809bfc08e04ec7c4", "tasks/ci-sharing-r-field-trip-test-s0/environment/team/scenario/notes.md": "ee5fd3b77bf18432325bb4d74e70f262c036ede162e5358cbf46a89e608c7fe1", "tasks/ci-sharing-r-field-trip-test-s0/environment/team/scenario/raw_excerpt.txt": "655626d175e3b1bac0052fd24a6329d9ff8ecc1120d8ee8ddbe40df4ad033a28", "tasks/ci-sharing-r-field-trip-test-s0/environment/team/scenario/record.json": "4741c0dcd8eb002f2225d302fe7603e7a8352f631f396e5b4de2a7f1edeb71ed", "tasks/ci-sharing-r-field-trip-test-s0/environment/team/scenario/source.md": "8e54e3637b410741a05fc79a9c261530bfebb29bdec0bcdc8f9b326800e8ab5b", - "tasks/ci-sharing-r-field-trip-test-s0/environment/team/task.json": "2f61714d15cf7f0d263bdb78f86b482f0e3b112043fc9488da91c4f9e97445c6", + "tasks/ci-sharing-r-field-trip-test-s0/environment/team/task.json": "a20791d29f877559c3965f92c7d94486b54a295e514cfc5b9208a65a5d9a6308", "tasks/ci-sharing-r-field-trip-test-s0/instruction.md": "dc34141076e3ce156787edc848535ebfb2f92fc84a4b25f1f9d68ad5167dd2fc", "tasks/ci-sharing-r-field-trip-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-field-trip-test-s0/solution/policy.json": "638caa2f98fe41dd865722ee32353d80d67b9ad5f4f7f125a6c511659ce9a02f", "tasks/ci-sharing-r-field-trip-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-field-trip-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-field-trip-test-s0/task.toml": "529667515fa5f0563684228cefdeaf6e4f095e50e7d72cc15e3ea46bdc04fef0", + "tasks/ci-sharing-r-field-trip-test-s0/task.toml": "007c550a94652a00e6895b31c65ec02075a271e128e59de4bb12b332e1a788dd", "tasks/ci-sharing-r-field-trip-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-field-trip-test-s0/tests/expected.json": "b246541697e75a7e3a9864f70d38ea23e1ac2e173b68e70817c3d8977e13c60e", "tasks/ci-sharing-r-field-trip-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-field-trip-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-field-trip-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-field-trip-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-field-trip-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-field-trip-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-field-trip-test-s0/tests/scenario/episode.yaml": "1c03810dcbdcbe513d2da954d0aa89a1b3aa7205e0f6d87c809bfc08e04ec7c4", "tasks/ci-sharing-r-field-trip-test-s0/tests/scenario/notes.md": "ee5fd3b77bf18432325bb4d74e70f262c036ede162e5358cbf46a89e608c7fe1", "tasks/ci-sharing-r-field-trip-test-s0/tests/scenario/raw_excerpt.txt": "655626d175e3b1bac0052fd24a6329d9ff8ecc1120d8ee8ddbe40df4ad033a28", @@ -7538,32 +7542,32 @@ "tasks/ci-sharing-r-field-trip-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-field-trip-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-field-trip-test-s1/environment/docker-compose.yaml": "2c99c5074a21c5cc023e69a21ff1153fbd9a3c3e97f98c88c89bee674730906b", - "tasks/ci-sharing-r-field-trip-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-field-trip-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-field-trip-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-field-trip-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-field-trip-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-field-trip-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-field-trip-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-field-trip-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-field-trip-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-field-trip-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-field-trip-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-field-trip-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-field-trip-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-field-trip-test-s1/environment/team/scenario/episode.yaml": "1c03810dcbdcbe513d2da954d0aa89a1b3aa7205e0f6d87c809bfc08e04ec7c4", "tasks/ci-sharing-r-field-trip-test-s1/environment/team/scenario/notes.md": "ee5fd3b77bf18432325bb4d74e70f262c036ede162e5358cbf46a89e608c7fe1", "tasks/ci-sharing-r-field-trip-test-s1/environment/team/scenario/raw_excerpt.txt": "655626d175e3b1bac0052fd24a6329d9ff8ecc1120d8ee8ddbe40df4ad033a28", "tasks/ci-sharing-r-field-trip-test-s1/environment/team/scenario/record.json": "4741c0dcd8eb002f2225d302fe7603e7a8352f631f396e5b4de2a7f1edeb71ed", "tasks/ci-sharing-r-field-trip-test-s1/environment/team/scenario/source.md": "8e54e3637b410741a05fc79a9c261530bfebb29bdec0bcdc8f9b326800e8ab5b", - "tasks/ci-sharing-r-field-trip-test-s1/environment/team/task.json": "7339ebaf45ce377ec67e47fff7d58b61c852b0b936cd1840fc39ff3ffbf447d3", + "tasks/ci-sharing-r-field-trip-test-s1/environment/team/task.json": "641d7a096239de01a83927cbed5fcaa5e014d3d8b5c8c8da7aaea45026de10e5", "tasks/ci-sharing-r-field-trip-test-s1/instruction.md": "dc34141076e3ce156787edc848535ebfb2f92fc84a4b25f1f9d68ad5167dd2fc", "tasks/ci-sharing-r-field-trip-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-field-trip-test-s1/solution/policy.json": "638caa2f98fe41dd865722ee32353d80d67b9ad5f4f7f125a6c511659ce9a02f", "tasks/ci-sharing-r-field-trip-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-field-trip-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-field-trip-test-s1/task.toml": "84e9465d52fc4b825f5a908b06d7dfb99c8e7f52a5ed70781550210abcfb9eb3", + "tasks/ci-sharing-r-field-trip-test-s1/task.toml": "0d6e4d45a28c6408d38e0408634f9f3a7ed42a8e0efe1a51dd2fa32b2eb40ab5", "tasks/ci-sharing-r-field-trip-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-field-trip-test-s1/tests/expected.json": "920c0855202da997889a4061c4c3c916ba81c36af6573784af08fd7dd5653be3", "tasks/ci-sharing-r-field-trip-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-field-trip-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-field-trip-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-field-trip-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-field-trip-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-field-trip-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-field-trip-test-s1/tests/scenario/episode.yaml": "1c03810dcbdcbe513d2da954d0aa89a1b3aa7205e0f6d87c809bfc08e04ec7c4", "tasks/ci-sharing-r-field-trip-test-s1/tests/scenario/notes.md": "ee5fd3b77bf18432325bb4d74e70f262c036ede162e5358cbf46a89e608c7fe1", "tasks/ci-sharing-r-field-trip-test-s1/tests/scenario/raw_excerpt.txt": "655626d175e3b1bac0052fd24a6329d9ff8ecc1120d8ee8ddbe40df4ad033a28", @@ -7583,32 +7587,32 @@ "tasks/ci-sharing-r-field-trip-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-r-field-trip-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-r-field-trip-test-s2/environment/docker-compose.yaml": "229c71891adcce64067d6168085ca4e35b8ecbe6579a5eadf59a063f0743545f", - "tasks/ci-sharing-r-field-trip-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-r-field-trip-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-r-field-trip-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-r-field-trip-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-r-field-trip-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-r-field-trip-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-r-field-trip-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-r-field-trip-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-field-trip-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-field-trip-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-field-trip-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-field-trip-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-field-trip-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-field-trip-test-s2/environment/team/scenario/episode.yaml": "1c03810dcbdcbe513d2da954d0aa89a1b3aa7205e0f6d87c809bfc08e04ec7c4", "tasks/ci-sharing-r-field-trip-test-s2/environment/team/scenario/notes.md": "ee5fd3b77bf18432325bb4d74e70f262c036ede162e5358cbf46a89e608c7fe1", "tasks/ci-sharing-r-field-trip-test-s2/environment/team/scenario/raw_excerpt.txt": "655626d175e3b1bac0052fd24a6329d9ff8ecc1120d8ee8ddbe40df4ad033a28", "tasks/ci-sharing-r-field-trip-test-s2/environment/team/scenario/record.json": "4741c0dcd8eb002f2225d302fe7603e7a8352f631f396e5b4de2a7f1edeb71ed", "tasks/ci-sharing-r-field-trip-test-s2/environment/team/scenario/source.md": "8e54e3637b410741a05fc79a9c261530bfebb29bdec0bcdc8f9b326800e8ab5b", - "tasks/ci-sharing-r-field-trip-test-s2/environment/team/task.json": "1fae30f1de3c7e7797200764fd08ccc19ecefd8d2e04845ba1e53e9f8b7af9be", + "tasks/ci-sharing-r-field-trip-test-s2/environment/team/task.json": "d6faae9ba12c82d01277e9d2d0e82716d95e3a15192cd409dc08d8e1deb0b35e", "tasks/ci-sharing-r-field-trip-test-s2/instruction.md": "dc34141076e3ce156787edc848535ebfb2f92fc84a4b25f1f9d68ad5167dd2fc", "tasks/ci-sharing-r-field-trip-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-r-field-trip-test-s2/solution/policy.json": "638caa2f98fe41dd865722ee32353d80d67b9ad5f4f7f125a6c511659ce9a02f", "tasks/ci-sharing-r-field-trip-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-r-field-trip-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-r-field-trip-test-s2/task.toml": "1f6cb8d0f31b46eb3711110975228227fb6f6f336628dc3050a759e5b2286592", + "tasks/ci-sharing-r-field-trip-test-s2/task.toml": "6514d102588a37e1b77d495d3abafcc3f1072ce51e8333623f2291e4c30b0d6f", "tasks/ci-sharing-r-field-trip-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-r-field-trip-test-s2/tests/expected.json": "0f77de94685db347e7b1780054af7cad678c43234ec7bd52e6d2c6327308ca80", "tasks/ci-sharing-r-field-trip-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-r-field-trip-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-r-field-trip-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-r-field-trip-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-r-field-trip-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-r-field-trip-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-r-field-trip-test-s2/tests/scenario/episode.yaml": "1c03810dcbdcbe513d2da954d0aa89a1b3aa7205e0f6d87c809bfc08e04ec7c4", "tasks/ci-sharing-r-field-trip-test-s2/tests/scenario/notes.md": "ee5fd3b77bf18432325bb4d74e70f262c036ede162e5358cbf46a89e608c7fe1", "tasks/ci-sharing-r-field-trip-test-s2/tests/scenario/raw_excerpt.txt": "655626d175e3b1bac0052fd24a6329d9ff8ecc1120d8ee8ddbe40df4ad033a28", @@ -7628,31 +7632,31 @@ "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/docker-compose.yaml": "0480ae67330ba289d585534cf454e1488a0ee4b0eab3596cabe22d5a706aa216", - "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/team/scenario/episode.yaml": "92959a960400ee0fe71037aa72512f91d7d34241e749c306da83b65a825d8fac", "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/team/scenario/notes.md": "9963307e05727b8811225365981f0a9c743b3983282d079a07d107124b48ea0c", "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/team/scenario/record.json": "ec1530bbb7b013c6e41b35f4892f8d2f133f6a85265f47361e30b1349bd64d7b", "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/team/scenario/source.md": "3f86167b9da0a754cf7c5915fd1f28afdb69d314b1535af3ddf074a2bc893d4f", - "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/team/task.json": "9147f48574401d5fbf98babd9ec6fb98e8a119e16930fddb1263f224f861f7d2", + "tasks/ci-sharing-x-sensor-placement-solo-s0/environment/team/task.json": "17dd8628ee448c7fb56969f0fa02732a1ff22c8da162493d442a618e35fed7d6", "tasks/ci-sharing-x-sensor-placement-solo-s0/instruction.md": "cc665eb3fac3f1e9c5377df95203109eafb8698841b792f1921afb5356c2bcfa", "tasks/ci-sharing-x-sensor-placement-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-x-sensor-placement-solo-s0/solution/policy.json": "080f97c07ddee9ed3f2b522a12657597f99f1c949422962d64cc775c1defc225", "tasks/ci-sharing-x-sensor-placement-solo-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-x-sensor-placement-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-x-sensor-placement-solo-s0/task.toml": "b6e2594e2e949f4186da1a6305792fb3bc6ec3fa1329f16adf0d55ef75e50cbc", + "tasks/ci-sharing-x-sensor-placement-solo-s0/task.toml": "8d77db1377f81d3bc7c9594762fed4682bc406642e1fcca31dc107d720f1b6a7", "tasks/ci-sharing-x-sensor-placement-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-x-sensor-placement-solo-s0/tests/expected.json": "3fbe44476c931908d6cafda9bc5a570b6c6488de6dfef452fef979886e783491", "tasks/ci-sharing-x-sensor-placement-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-x-sensor-placement-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-x-sensor-placement-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-x-sensor-placement-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-x-sensor-placement-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-x-sensor-placement-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-x-sensor-placement-solo-s0/tests/scenario/episode.yaml": "92959a960400ee0fe71037aa72512f91d7d34241e749c306da83b65a825d8fac", "tasks/ci-sharing-x-sensor-placement-solo-s0/tests/scenario/notes.md": "9963307e05727b8811225365981f0a9c743b3983282d079a07d107124b48ea0c", "tasks/ci-sharing-x-sensor-placement-solo-s0/tests/scenario/record.json": "ec1530bbb7b013c6e41b35f4892f8d2f133f6a85265f47361e30b1349bd64d7b", @@ -7671,31 +7675,31 @@ "tasks/ci-sharing-x-sensor-placement-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-x-sensor-placement-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-x-sensor-placement-test-s0/environment/docker-compose.yaml": "20a81db223e4bec53004f94418690036b1cb664415393504f2d2d6bab94a1902", - "tasks/ci-sharing-x-sensor-placement-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-x-sensor-placement-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-x-sensor-placement-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-x-sensor-placement-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-x-sensor-placement-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-x-sensor-placement-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-x-sensor-placement-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-x-sensor-placement-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-x-sensor-placement-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-x-sensor-placement-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-x-sensor-placement-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-x-sensor-placement-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-x-sensor-placement-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-x-sensor-placement-test-s0/environment/team/scenario/episode.yaml": "92959a960400ee0fe71037aa72512f91d7d34241e749c306da83b65a825d8fac", "tasks/ci-sharing-x-sensor-placement-test-s0/environment/team/scenario/notes.md": "9963307e05727b8811225365981f0a9c743b3983282d079a07d107124b48ea0c", "tasks/ci-sharing-x-sensor-placement-test-s0/environment/team/scenario/record.json": "ec1530bbb7b013c6e41b35f4892f8d2f133f6a85265f47361e30b1349bd64d7b", "tasks/ci-sharing-x-sensor-placement-test-s0/environment/team/scenario/source.md": "3f86167b9da0a754cf7c5915fd1f28afdb69d314b1535af3ddf074a2bc893d4f", - "tasks/ci-sharing-x-sensor-placement-test-s0/environment/team/task.json": "2edd7956bd8f60526c010f8d9ee910327cc28ac00b8d75d9deda1a566e31cc0c", + "tasks/ci-sharing-x-sensor-placement-test-s0/environment/team/task.json": "cba30515d5f127357b4814932a5bce790782b36121cafa64abc5a3baa8d3eaf8", "tasks/ci-sharing-x-sensor-placement-test-s0/instruction.md": "e335866c263a141e7a1e0bb575d40d55de12c8a71c9a1b593c14e788741e6f3a", "tasks/ci-sharing-x-sensor-placement-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-x-sensor-placement-test-s0/solution/policy.json": "080f97c07ddee9ed3f2b522a12657597f99f1c949422962d64cc775c1defc225", "tasks/ci-sharing-x-sensor-placement-test-s0/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-x-sensor-placement-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-x-sensor-placement-test-s0/task.toml": "91ab9c55e7725b571135ed32a3378d105c05d244d90ade5bf237361414dc2cdb", + "tasks/ci-sharing-x-sensor-placement-test-s0/task.toml": "997e64c10cee3966a3199bcbffbe701a8b08ccd11cc57ae46222f2a2b32bc0e1", "tasks/ci-sharing-x-sensor-placement-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-x-sensor-placement-test-s0/tests/expected.json": "8063a0f20d10f91564b39fc6a3b43b36ec4715eeadf9dc996213ec0692a1f1d2", "tasks/ci-sharing-x-sensor-placement-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-x-sensor-placement-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-x-sensor-placement-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-x-sensor-placement-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-x-sensor-placement-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-x-sensor-placement-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-x-sensor-placement-test-s0/tests/scenario/episode.yaml": "92959a960400ee0fe71037aa72512f91d7d34241e749c306da83b65a825d8fac", "tasks/ci-sharing-x-sensor-placement-test-s0/tests/scenario/notes.md": "9963307e05727b8811225365981f0a9c743b3983282d079a07d107124b48ea0c", "tasks/ci-sharing-x-sensor-placement-test-s0/tests/scenario/record.json": "ec1530bbb7b013c6e41b35f4892f8d2f133f6a85265f47361e30b1349bd64d7b", @@ -7714,31 +7718,31 @@ "tasks/ci-sharing-x-sensor-placement-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-x-sensor-placement-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-x-sensor-placement-test-s1/environment/docker-compose.yaml": "7199c2171c795999185ea1b51098e37286b20f0171a38eca720ea543d483ed55", - "tasks/ci-sharing-x-sensor-placement-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-x-sensor-placement-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-x-sensor-placement-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-x-sensor-placement-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-x-sensor-placement-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-x-sensor-placement-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-x-sensor-placement-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-x-sensor-placement-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-x-sensor-placement-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-x-sensor-placement-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-x-sensor-placement-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-x-sensor-placement-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-x-sensor-placement-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-x-sensor-placement-test-s1/environment/team/scenario/episode.yaml": "92959a960400ee0fe71037aa72512f91d7d34241e749c306da83b65a825d8fac", "tasks/ci-sharing-x-sensor-placement-test-s1/environment/team/scenario/notes.md": "9963307e05727b8811225365981f0a9c743b3983282d079a07d107124b48ea0c", "tasks/ci-sharing-x-sensor-placement-test-s1/environment/team/scenario/record.json": "ec1530bbb7b013c6e41b35f4892f8d2f133f6a85265f47361e30b1349bd64d7b", "tasks/ci-sharing-x-sensor-placement-test-s1/environment/team/scenario/source.md": "3f86167b9da0a754cf7c5915fd1f28afdb69d314b1535af3ddf074a2bc893d4f", - "tasks/ci-sharing-x-sensor-placement-test-s1/environment/team/task.json": "8eda40688f1790db412ddf600315cfb9e7f6bdf6c71c28974f7fe9044b1930db", + "tasks/ci-sharing-x-sensor-placement-test-s1/environment/team/task.json": "cb71e5e3292861894c546f237c2789d074bc847ff145bbd42da99ec1ac06bc6e", "tasks/ci-sharing-x-sensor-placement-test-s1/instruction.md": "e335866c263a141e7a1e0bb575d40d55de12c8a71c9a1b593c14e788741e6f3a", "tasks/ci-sharing-x-sensor-placement-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-x-sensor-placement-test-s1/solution/policy.json": "080f97c07ddee9ed3f2b522a12657597f99f1c949422962d64cc775c1defc225", "tasks/ci-sharing-x-sensor-placement-test-s1/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-x-sensor-placement-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-x-sensor-placement-test-s1/task.toml": "f5b662f3a836623713bf6035e8f727c8cbfefe8d36296dc9ed73ebc3241c1b22", + "tasks/ci-sharing-x-sensor-placement-test-s1/task.toml": "cbbf969ae953738709e3d3fb2255904a90cba7b78decdc4b1dfaa6d59d4ffaca", "tasks/ci-sharing-x-sensor-placement-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-x-sensor-placement-test-s1/tests/expected.json": "3e3d13310e24f085319e05bf91d40ab52775d39baebb6943e934def335df8fef", "tasks/ci-sharing-x-sensor-placement-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-x-sensor-placement-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-x-sensor-placement-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-x-sensor-placement-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-x-sensor-placement-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-x-sensor-placement-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-x-sensor-placement-test-s1/tests/scenario/episode.yaml": "92959a960400ee0fe71037aa72512f91d7d34241e749c306da83b65a825d8fac", "tasks/ci-sharing-x-sensor-placement-test-s1/tests/scenario/notes.md": "9963307e05727b8811225365981f0a9c743b3983282d079a07d107124b48ea0c", "tasks/ci-sharing-x-sensor-placement-test-s1/tests/scenario/record.json": "ec1530bbb7b013c6e41b35f4892f8d2f133f6a85265f47361e30b1349bd64d7b", @@ -7757,31 +7761,31 @@ "tasks/ci-sharing-x-sensor-placement-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-sharing-x-sensor-placement-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-sharing-x-sensor-placement-test-s2/environment/docker-compose.yaml": "786d3dae7fe9d2eaf0e3fc0cf64aee9e7d7b0d9fdd8bd1fc3e5fdc9d3877419a", - "tasks/ci-sharing-x-sensor-placement-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-sharing-x-sensor-placement-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-sharing-x-sensor-placement-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-sharing-x-sensor-placement-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-sharing-x-sensor-placement-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-sharing-x-sensor-placement-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-sharing-x-sensor-placement-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-sharing-x-sensor-placement-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-x-sensor-placement-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-x-sensor-placement-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-x-sensor-placement-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-x-sensor-placement-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-x-sensor-placement-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-x-sensor-placement-test-s2/environment/team/scenario/episode.yaml": "92959a960400ee0fe71037aa72512f91d7d34241e749c306da83b65a825d8fac", "tasks/ci-sharing-x-sensor-placement-test-s2/environment/team/scenario/notes.md": "9963307e05727b8811225365981f0a9c743b3983282d079a07d107124b48ea0c", "tasks/ci-sharing-x-sensor-placement-test-s2/environment/team/scenario/record.json": "ec1530bbb7b013c6e41b35f4892f8d2f133f6a85265f47361e30b1349bd64d7b", "tasks/ci-sharing-x-sensor-placement-test-s2/environment/team/scenario/source.md": "3f86167b9da0a754cf7c5915fd1f28afdb69d314b1535af3ddf074a2bc893d4f", - "tasks/ci-sharing-x-sensor-placement-test-s2/environment/team/task.json": "adee62c03f4db52d55543cb01c7b122d93c5f5b14216d56592ad45f92768c3ba", + "tasks/ci-sharing-x-sensor-placement-test-s2/environment/team/task.json": "31326d3a20c9e6c33c86ef557605e7c729038d6d7842d4dea08eeba93b2614f3", "tasks/ci-sharing-x-sensor-placement-test-s2/instruction.md": "e335866c263a141e7a1e0bb575d40d55de12c8a71c9a1b593c14e788741e6f3a", "tasks/ci-sharing-x-sensor-placement-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-sharing-x-sensor-placement-test-s2/solution/policy.json": "080f97c07ddee9ed3f2b522a12657597f99f1c949422962d64cc775c1defc225", "tasks/ci-sharing-x-sensor-placement-test-s2/solution/solve.sh": "541bc931b06d557feb61b24bdf2e61f9128aff37a8707810808da0e801dbf735", "tasks/ci-sharing-x-sensor-placement-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-sharing-x-sensor-placement-test-s2/task.toml": "a24a29dc6a5f4a7afe774fa1398d9ece64b593eb79e85b59c9ad1072ebece467", + "tasks/ci-sharing-x-sensor-placement-test-s2/task.toml": "2b147d657da4147969fb62f7ee33d9c0712890e181ecc5fac0f8af54bcaeefd6", "tasks/ci-sharing-x-sensor-placement-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-sharing-x-sensor-placement-test-s2/tests/expected.json": "e32f779a1af7cf30098a31e0352a8692b4c4753c13ef73ed9c9dbfaa1092d0b5", "tasks/ci-sharing-x-sensor-placement-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-sharing-x-sensor-placement-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-sharing-x-sensor-placement-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-sharing-x-sensor-placement-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-sharing-x-sensor-placement-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-sharing-x-sensor-placement-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-sharing-x-sensor-placement-test-s2/tests/scenario/episode.yaml": "92959a960400ee0fe71037aa72512f91d7d34241e749c306da83b65a825d8fac", "tasks/ci-sharing-x-sensor-placement-test-s2/tests/scenario/notes.md": "9963307e05727b8811225365981f0a9c743b3983282d079a07d107124b48ea0c", "tasks/ci-sharing-x-sensor-placement-test-s2/tests/scenario/record.json": "ec1530bbb7b013c6e41b35f4892f8d2f133f6a85265f47361e30b1349bd64d7b", @@ -7800,19 +7804,19 @@ "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/docker-compose.yaml": "ae3f6b58dcbc1d9e508643332dcc4246614aec6362c48308c11137c2bdc3375c", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/team/scenario/episode.yaml": "353df08eb91f69e77bde64e398feffa59a52e897aab04c06e2be07a9639cc602", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/team/scenario/notes.md": "e75aaf9044ab9a51560e26159b5783067f121efc59789b2da3de234fb5c8c096", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/team/scenario/record.json": "3e626d2b6a36621ae6fff16621018a45ed2763f76716f99e45312fa4568545a8", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/team/scenario/source.md": "48325fa7aa32b82a2f4c42bd6d4c4a0aa266ec2589f4acbecfdbeac21d5c62d8", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/team/task.json": "b44fbe83829e31ec058aaeb1d7057bf6eef766a96c2936b980d887091a0dc278", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/team/task.json": "73265aa6f4caf373629acd47021454af556a8ec957e8081d5216a6bab1a962c1", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -7825,13 +7829,13 @@ "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/task.toml": "82cf8be10e9234028f81a27ae61fcd16894af26d16f76fc1e921a061c2d5c537", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/task.toml": "d192713d54c67e7d1ed270e527d5b48c101f7b69a0c622048e704c24596a470b", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/tests/expected.json": "92afa4bc36d21643f1c6bddd87db3b328464f0ab44af4df5e0b4d827915615db", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/tests/scenario/episode.yaml": "353df08eb91f69e77bde64e398feffa59a52e897aab04c06e2be07a9639cc602", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/tests/scenario/notes.md": "e75aaf9044ab9a51560e26159b5783067f121efc59789b2da3de234fb5c8c096", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/tests/scenario/record.json": "3e626d2b6a36621ae6fff16621018a45ed2763f76716f99e45312fa4568545a8", @@ -7850,19 +7854,19 @@ "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/docker-compose.yaml": "945448379dc60932e726f44a08e9687c0ff96afea4bd92ddd7af65375af4f8db", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/team/scenario/episode.yaml": "261fd8c7bb96296b9f07ea54a695235d500065a7add696274e8437a9961b1c45", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/team/scenario/notes.md": "e006f074af1c008fa7178dc5e665ef0a2f876fa15b973df705775c189e1dea24", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/team/scenario/record.json": "379cf5abeffb6678bedc34231ccd0a5ea9040517baade7cb002e51364da5273b", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/team/scenario/source.md": "49fe380d20e724413576a08e9c34286a0b5fb339553d7af4cd74d900505d1c6d", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/team/task.json": "c35c59fc260de7bfd7655f284e2b0fa31d211d9557d1dae8f24532c61a4b2792", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/team/task.json": "ea06084fe0e1cc85d9369380f6ed881c7f80f7f538455e56b8ee9c128518adf9", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -7875,13 +7879,13 @@ "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/task.toml": "98e10a710586845b29e4d7b9c5320db1bc8ac42b06d9e4c663b731790d493696", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/task.toml": "4a5ae1aedb18e1d9326f032f67b0a0b9b09ef7691a6dfa99b8c335cb00a5178b", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/tests/expected.json": "94ee66e4c17ac4a8830fab8ea2e84b7dcfc439bb2d6d11766ed7351254c544c7", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/tests/scenario/episode.yaml": "261fd8c7bb96296b9f07ea54a695235d500065a7add696274e8437a9961b1c45", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/tests/scenario/notes.md": "e006f074af1c008fa7178dc5e665ef0a2f876fa15b973df705775c189e1dea24", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/tests/scenario/record.json": "379cf5abeffb6678bedc34231ccd0a5ea9040517baade7cb002e51364da5273b", @@ -7900,19 +7904,19 @@ "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/docker-compose.yaml": "6be1588ed57d5dd2578b25923c8db6b0b2ac2ddc2856cf5d7903d96e389167ef", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/team/scenario/episode.yaml": "353df08eb91f69e77bde64e398feffa59a52e897aab04c06e2be07a9639cc602", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/team/scenario/notes.md": "e75aaf9044ab9a51560e26159b5783067f121efc59789b2da3de234fb5c8c096", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/team/scenario/record.json": "3e626d2b6a36621ae6fff16621018a45ed2763f76716f99e45312fa4568545a8", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/team/scenario/source.md": "48325fa7aa32b82a2f4c42bd6d4c4a0aa266ec2589f4acbecfdbeac21d5c62d8", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/team/task.json": "71e52599c1010ae1c037ab637d9d1be5a0472e683d485488d8f0cf0a1069c6ce", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/team/task.json": "edf6ccc239408cf90ff6a23909306ad716cf25a0c214b87ca429456daac3df16", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -7925,13 +7929,13 @@ "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/task.toml": "c0ca4503a7c528977ae492f0a1de9094fac7e22e5ae7df0d3f7ee783e9f338f1", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/task.toml": "71b35045983f41913e81373e20127eb75afd410e401be059bb1da48dce4113da", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/tests/expected.json": "bd30193ffd62395b64294b17776e1c420abea726429afdb3ffa05b1860014298", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/tests/scenario/episode.yaml": "353df08eb91f69e77bde64e398feffa59a52e897aab04c06e2be07a9639cc602", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/tests/scenario/notes.md": "e75aaf9044ab9a51560e26159b5783067f121efc59789b2da3de234fb5c8c096", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/tests/scenario/record.json": "3e626d2b6a36621ae6fff16621018a45ed2763f76716f99e45312fa4568545a8", @@ -7950,19 +7954,19 @@ "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/docker-compose.yaml": "3ad99dbaeb1907c5c2ab343f50dff299e452e4822da5f2214f72cea644110e18", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/team/scenario/episode.yaml": "353df08eb91f69e77bde64e398feffa59a52e897aab04c06e2be07a9639cc602", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/team/scenario/notes.md": "e75aaf9044ab9a51560e26159b5783067f121efc59789b2da3de234fb5c8c096", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/team/scenario/record.json": "3e626d2b6a36621ae6fff16621018a45ed2763f76716f99e45312fa4568545a8", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/team/scenario/source.md": "48325fa7aa32b82a2f4c42bd6d4c4a0aa266ec2589f4acbecfdbeac21d5c62d8", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/team/task.json": "a7eb5afa68b3be07628151c705dd07732e6eca328172ef4f2c0e487d57ed05f7", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/team/task.json": "e1229c7d9a3831c990b5fb5e57275188efe7ddcc1e1a5a31e15cfb9bf408336b", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -7975,13 +7979,13 @@ "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/task.toml": "73de81ad42f0e9c3735fc2727cd0962f31e39a1a8ddfe7b0b287783e72922078", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/task.toml": "d39038fd8b3ebb1d0e4f3bae32fcfa09e534178bd9f4eb262ad9c22869707aec", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/tests/expected.json": "d1448ccca8992f3109d5e5e6c6154f36660fae83223b2a292d346d76d9cbe373", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/tests/scenario/episode.yaml": "353df08eb91f69e77bde64e398feffa59a52e897aab04c06e2be07a9639cc602", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/tests/scenario/notes.md": "e75aaf9044ab9a51560e26159b5783067f121efc59789b2da3de234fb5c8c096", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/tests/scenario/record.json": "3e626d2b6a36621ae6fff16621018a45ed2763f76716f99e45312fa4568545a8", @@ -8000,19 +8004,19 @@ "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/docker-compose.yaml": "c365015beae3b90e4c150e7c644f821245e38ef0eb9a8fcad752bb15d6d35247", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/team/scenario/episode.yaml": "353df08eb91f69e77bde64e398feffa59a52e897aab04c06e2be07a9639cc602", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/team/scenario/notes.md": "e75aaf9044ab9a51560e26159b5783067f121efc59789b2da3de234fb5c8c096", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/team/scenario/record.json": "3e626d2b6a36621ae6fff16621018a45ed2763f76716f99e45312fa4568545a8", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/team/scenario/source.md": "48325fa7aa32b82a2f4c42bd6d4c4a0aa266ec2589f4acbecfdbeac21d5c62d8", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/team/task.json": "961b75906a7470890836366373c2d7424c5ea01de8f884cfe994ece97d613116", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/team/task.json": "c262614f5983cf5ba3b748924c8f88b48ef67909cee02c354334d5799a492ed6", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8025,13 +8029,13 @@ "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/task.toml": "2e6fb09f2c401dce9a35cd1e8bc9c71dbae634e8dfbee33d42d6e6cfbfe4b6db", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/task.toml": "4f3d60ddfa6805707fa56dc59f8425617ede3b389690b415e21539a8080cef3a", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/tests/expected.json": "13c5d56746984a55a5b567797e9b77741df3630cae42eb4a123b9700c539fa38", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/tests/scenario/episode.yaml": "353df08eb91f69e77bde64e398feffa59a52e897aab04c06e2be07a9639cc602", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/tests/scenario/notes.md": "e75aaf9044ab9a51560e26159b5783067f121efc59789b2da3de234fb5c8c096", "tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/tests/scenario/record.json": "3e626d2b6a36621ae6fff16621018a45ed2763f76716f99e45312fa4568545a8", @@ -8050,19 +8054,19 @@ "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/docker-compose.yaml": "f56cea52d72d478ec66407febdde2f6f963208a15904e6f80fc742ef731c6e1a", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/team/scenario/episode.yaml": "b91a631a41830e1f8080bdcaf5454b98648d51d58c6d0b491ef88547b68c5fef", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/team/scenario/notes.md": "f4715f6e3583dbed3014cc02e9373e4ca54b8cd29d6c612aa1a1ed95460f1890", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/team/scenario/record.json": "bde15794f3f37cfbf14d479bc1bb6dbb7210dd06106480f5df92077fe993f478", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/team/scenario/source.md": "e1d5cfc3bd143e4aac393dd5a8cf87f96832d599c11404ee2b7aed29e169be04", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/team/task.json": "259253ffa7b01c1c3135bda0f16b5ec235a72b3c013094ff92a8f32ccd5b575e", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/team/task.json": "e07272f464788d6e1f217406bbc75588c9655426228fafdb3d9af5bfe737f337", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8075,13 +8079,13 @@ "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/task.toml": "f0d4990195fb14cf6228ae3af927319e4fb94431d07db3b104ccc4d0eb3c51ae", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/task.toml": "9b46535001252afd568f4e26aa009526089871ab8594473523a1538725983545", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/tests/expected.json": "1c9c91de43b0311def85bb3540e5fd0a8d1ed8f232adf56b86103df3ff4f8e1d", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/tests/scenario/episode.yaml": "b91a631a41830e1f8080bdcaf5454b98648d51d58c6d0b491ef88547b68c5fef", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/tests/scenario/notes.md": "f4715f6e3583dbed3014cc02e9373e4ca54b8cd29d6c612aa1a1ed95460f1890", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/tests/scenario/record.json": "bde15794f3f37cfbf14d479bc1bb6dbb7210dd06106480f5df92077fe993f478", @@ -8100,19 +8104,19 @@ "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/docker-compose.yaml": "ec20239c81f16d1eb0874c0177ddc27d9773aaae393f9a4400d5545d2b87d088", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/team/scenario/episode.yaml": "46697af8be9222750318ac50881cce0c155fb1fabab15d3150f7baad83499b5e", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/team/scenario/notes.md": "db1567fd8b0f2130fd741074e81959ea3f20472a776bf2fdfdb0df25c8f94b8a", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/team/scenario/record.json": "2f5318bd03500710dec4d069360493f1bdbb3591bfb77019cdc115dcc9494cb3", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/team/scenario/source.md": "d6595c3c411f6e5d667333640fbecdba046a454b419b3905f77915d82a4cfbaf", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/team/task.json": "24f3bea968a068b2b4099f10f9a10a954a9e724eea30f4f79a7f8229e953b7d6", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/team/task.json": "7951cb64d3841785d76c79586fc80fb9fdc8c11190520e135e40053d2b5fd336", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8125,13 +8129,13 @@ "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/task.toml": "5712d04f133fa06948b188ab5f9ee1a0a7be71d4be2609ebbaf0b4e60bba56c8", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/task.toml": "4a0b11ea818ab60f32df1b02e8bbddfe433bdec539f3211a6ac0acf39f8554ad", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/tests/expected.json": "d18ce30b6a600bc76d67248bdc22d8a842e4e4c188bb12bcbeeee378c4ec1f38", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/tests/scenario/episode.yaml": "46697af8be9222750318ac50881cce0c155fb1fabab15d3150f7baad83499b5e", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/tests/scenario/notes.md": "db1567fd8b0f2130fd741074e81959ea3f20472a776bf2fdfdb0df25c8f94b8a", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/tests/scenario/record.json": "2f5318bd03500710dec4d069360493f1bdbb3591bfb77019cdc115dcc9494cb3", @@ -8150,19 +8154,19 @@ "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/docker-compose.yaml": "7684151e42e7a330c14be50b871e84fa0558c8db830a1d3f99cef9c85ea300a1", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/team/scenario/episode.yaml": "b91a631a41830e1f8080bdcaf5454b98648d51d58c6d0b491ef88547b68c5fef", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/team/scenario/notes.md": "f4715f6e3583dbed3014cc02e9373e4ca54b8cd29d6c612aa1a1ed95460f1890", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/team/scenario/record.json": "bde15794f3f37cfbf14d479bc1bb6dbb7210dd06106480f5df92077fe993f478", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/team/scenario/source.md": "e1d5cfc3bd143e4aac393dd5a8cf87f96832d599c11404ee2b7aed29e169be04", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/team/task.json": "b708c783491a730453bc41f142d193d41ea7454dd02695c465f69eb332c19915", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/team/task.json": "4e8b0b060846d4363a2f17abfcd060a14459d73e30d3ea4bd1b3865a716bbeb6", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8175,13 +8179,13 @@ "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/task.toml": "681407782fb6a00e2fd909f9085b0852fbab43ae7ef1027e6ce50a8733e86314", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/task.toml": "c54c970648395c66906b5fdccd19978c1f3490fcd9f854d2e9c6dbd7c4d54146", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/tests/expected.json": "b058ef458d2cd685791821f94c001e539ade0d9a8b77e7a56f6f6a55d856b731", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/tests/scenario/episode.yaml": "b91a631a41830e1f8080bdcaf5454b98648d51d58c6d0b491ef88547b68c5fef", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/tests/scenario/notes.md": "f4715f6e3583dbed3014cc02e9373e4ca54b8cd29d6c612aa1a1ed95460f1890", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/tests/scenario/record.json": "bde15794f3f37cfbf14d479bc1bb6dbb7210dd06106480f5df92077fe993f478", @@ -8200,19 +8204,19 @@ "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/docker-compose.yaml": "f0f3fd822936b11978d52643c9b4efddc0470fe9c609431a1d4bbb2e2d56b170", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/team/scenario/episode.yaml": "b91a631a41830e1f8080bdcaf5454b98648d51d58c6d0b491ef88547b68c5fef", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/team/scenario/notes.md": "f4715f6e3583dbed3014cc02e9373e4ca54b8cd29d6c612aa1a1ed95460f1890", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/team/scenario/record.json": "bde15794f3f37cfbf14d479bc1bb6dbb7210dd06106480f5df92077fe993f478", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/team/scenario/source.md": "e1d5cfc3bd143e4aac393dd5a8cf87f96832d599c11404ee2b7aed29e169be04", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/team/task.json": "24e51b117e429662fdf9f73c60d945059830e2fef33568c302a96578b17861de", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/team/task.json": "2390ea2dd7cfa2c7463130634e35b6d493c3eb969611cbcc8a138d767d52c52c", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8225,13 +8229,13 @@ "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/task.toml": "0b8eb23af835ec6cf59753f63e44b96241f820aeb44b09561e7e2265359165f2", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/task.toml": "31504104ec5fdd839ffa1919f79e00528c8435ed3498c52bc8f663f29608364b", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/tests/expected.json": "870ae40e119a0af79f42f64ff6ac45ec5b293cc92a5c432baf88d3e30153c935", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/tests/scenario/episode.yaml": "b91a631a41830e1f8080bdcaf5454b98648d51d58c6d0b491ef88547b68c5fef", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/tests/scenario/notes.md": "f4715f6e3583dbed3014cc02e9373e4ca54b8cd29d6c612aa1a1ed95460f1890", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/tests/scenario/record.json": "bde15794f3f37cfbf14d479bc1bb6dbb7210dd06106480f5df92077fe993f478", @@ -8250,19 +8254,19 @@ "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/docker-compose.yaml": "40309b1fadad85749c7f209ea7b2dc043f7526c92161daf57016adc44f606c65", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/team/scenario/episode.yaml": "b91a631a41830e1f8080bdcaf5454b98648d51d58c6d0b491ef88547b68c5fef", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/team/scenario/notes.md": "f4715f6e3583dbed3014cc02e9373e4ca54b8cd29d6c612aa1a1ed95460f1890", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/team/scenario/record.json": "bde15794f3f37cfbf14d479bc1bb6dbb7210dd06106480f5df92077fe993f478", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/team/scenario/source.md": "e1d5cfc3bd143e4aac393dd5a8cf87f96832d599c11404ee2b7aed29e169be04", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/team/task.json": "f20e6dbde660c889b257d8af91a515abb3ed3a9e44b10f3a81a7e1218716d1dd", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/team/task.json": "6f5f90e4a2c6ecd5a91b275160c06fc001edcecfbb255419807cc13ff6de9ce0", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8275,13 +8279,13 @@ "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/task.toml": "f189cae0930b173d1b3674a0dd442c6b790236e04d9612e7aebc96feeba98dd6", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/task.toml": "59e69ee28158bb7d90af63c9e42ca64340e8ebee23c8f045dcfe22c64ae4084b", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/tests/expected.json": "c337e4fd6c626b9fb69a707f09c90a6836da0b1f716dcec6c09b52ee77dfa678", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/tests/scenario/episode.yaml": "b91a631a41830e1f8080bdcaf5454b98648d51d58c6d0b491ef88547b68c5fef", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/tests/scenario/notes.md": "f4715f6e3583dbed3014cc02e9373e4ca54b8cd29d6c612aa1a1ed95460f1890", "tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/tests/scenario/record.json": "bde15794f3f37cfbf14d479bc1bb6dbb7210dd06106480f5df92077fe993f478", @@ -8300,19 +8304,19 @@ "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/docker-compose.yaml": "26a4791af6b3d3a95bcc1705841aea6769ca5f06511e861c56d5297dde92929f", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/team/scenario/episode.yaml": "f27a4805329b99f79e7db5fbf4ff05a7fe08acd80ca6e06281fa1c1775993a11", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/team/scenario/notes.md": "10b9f8c369d382dc97ebae40b37d8d5c67184478a0623bdd8a06eab7c43676b8", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/team/scenario/record.json": "c20f70dcf16f62e2c932aca40fbf3ef588e405709bb0a02d3b40c1858173c165", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/team/scenario/source.md": "7d0db3c69288559cfb84e9a79febe72a9b88cf55a7289c5d83847e63e14ff181", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/team/task.json": "9011bac479c855c3435e795df11ae358d3668bf6a90dadfe7f90cf8bf4d2bfda", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/team/task.json": "dfa1704a3dba4253e5f4e3ee1c006bcbf618c3a953c0c6fd74870e2670c74b81", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8325,13 +8329,13 @@ "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/task.toml": "f1682a791c6d34d5c7ffbd974965b6140d2dbcc354e4cdd40e652703301f0a7a", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/task.toml": "1e25714835e7c785bd731c6d990adb9f60cc7e1e2fc819686339d7f331eed419", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/tests/expected.json": "21793379d40eebaf83823f64b1bb64017f08d67b1e44e45a970948bda4fed7c2", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/tests/scenario/episode.yaml": "f27a4805329b99f79e7db5fbf4ff05a7fe08acd80ca6e06281fa1c1775993a11", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/tests/scenario/notes.md": "10b9f8c369d382dc97ebae40b37d8d5c67184478a0623bdd8a06eab7c43676b8", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/tests/scenario/record.json": "c20f70dcf16f62e2c932aca40fbf3ef588e405709bb0a02d3b40c1858173c165", @@ -8350,19 +8354,19 @@ "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/docker-compose.yaml": "087b3466e2eb8cb6f2dfa895a3508843dd2c4cdfca821016f614a193a8bffa54", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/team/scenario/episode.yaml": "a0660d66f4edd98f09822f5478d773b6394c6c040ed4326145d4dc25d96b6fef", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/team/scenario/notes.md": "3634225a21ccd6a34b4852d7705a3d1310389336068754fcdda08fa631fd5a53", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/team/scenario/record.json": "c95f83497e7463ba1df9096c8b9e5bb4007226f3f82b9f8253061548b4570c33", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/team/scenario/source.md": "8d701de49f418d0485a62da6c29f650aab8113dc99e7e81b2bc9325738680ad9", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/team/task.json": "2a94a2a1df87a5d8050f97c9b99e4ed7e41c410b8a2847229f14d5048a82c9e6", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/team/task.json": "ff458b97f9f92952d78f81526dc022b992fc44774ff6f2b8f817d4266f90ab7b", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8375,13 +8379,13 @@ "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/task.toml": "9eca28c5574c2558453c585430a1450919a8f5c926b722ba330a75d895192afd", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/task.toml": "93273504098384d04c47e88ccc191762d74a3da5df86d405b59d48637f094d9b", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/tests/expected.json": "1e377f85ccf74e4245f0806de25bb4bbc9eded0966c22968236ed634a819525f", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/tests/scenario/episode.yaml": "a0660d66f4edd98f09822f5478d773b6394c6c040ed4326145d4dc25d96b6fef", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/tests/scenario/notes.md": "3634225a21ccd6a34b4852d7705a3d1310389336068754fcdda08fa631fd5a53", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/tests/scenario/record.json": "c95f83497e7463ba1df9096c8b9e5bb4007226f3f82b9f8253061548b4570c33", @@ -8400,19 +8404,19 @@ "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/docker-compose.yaml": "962e01f07e2335a5eec7b3d5b271d631c2ded734013343626de45ab8b5b334bd", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/team/scenario/episode.yaml": "f27a4805329b99f79e7db5fbf4ff05a7fe08acd80ca6e06281fa1c1775993a11", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/team/scenario/notes.md": "10b9f8c369d382dc97ebae40b37d8d5c67184478a0623bdd8a06eab7c43676b8", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/team/scenario/record.json": "c20f70dcf16f62e2c932aca40fbf3ef588e405709bb0a02d3b40c1858173c165", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/team/scenario/source.md": "7d0db3c69288559cfb84e9a79febe72a9b88cf55a7289c5d83847e63e14ff181", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/team/task.json": "3cfe5356a0ae9c1148d14e1337de74402d848ee3822f2de38d4a0bb6426b8be7", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/team/task.json": "08b8ad6972533436cd1b067e39f83ea8a08579210de7d3a6f72deb80cdda6e96", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8425,13 +8429,13 @@ "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/task.toml": "76beaba0bdd01b88fadbfc225e289b2ca154ba9e5135c7bf8f12a9e595f7a1ba", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/task.toml": "ca899ab181323f26e9f6c528ad277e1a8c16cd3ed4ca537d8220fe21b324b6ff", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/tests/expected.json": "d3727155818f72899533dc5ebf681a969c59c69bf11cee4bb5c2067a19b4647a", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/tests/scenario/episode.yaml": "f27a4805329b99f79e7db5fbf4ff05a7fe08acd80ca6e06281fa1c1775993a11", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/tests/scenario/notes.md": "10b9f8c369d382dc97ebae40b37d8d5c67184478a0623bdd8a06eab7c43676b8", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/tests/scenario/record.json": "c20f70dcf16f62e2c932aca40fbf3ef588e405709bb0a02d3b40c1858173c165", @@ -8450,19 +8454,19 @@ "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/docker-compose.yaml": "a269fc62a37eb0766c1a0fb4174d593ab5de23b10b12007f110535223fea0db8", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/team/scenario/episode.yaml": "f27a4805329b99f79e7db5fbf4ff05a7fe08acd80ca6e06281fa1c1775993a11", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/team/scenario/notes.md": "10b9f8c369d382dc97ebae40b37d8d5c67184478a0623bdd8a06eab7c43676b8", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/team/scenario/record.json": "c20f70dcf16f62e2c932aca40fbf3ef588e405709bb0a02d3b40c1858173c165", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/team/scenario/source.md": "7d0db3c69288559cfb84e9a79febe72a9b88cf55a7289c5d83847e63e14ff181", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/team/task.json": "4192ab668146370373b791eecf1765334ba2b5eb3279fff3c02bd9abbbbcd198", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/team/task.json": "67308a5f8ee47d9a030bf12f8e70d55d111cf68853d2103daef328c97e5684df", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8475,13 +8479,13 @@ "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/task.toml": "887b96ccbf2a81d4cf6824653a567eda6e2bb3321ff1f6efdaac1aa78f327163", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/task.toml": "16bb4b692b07da18d29731b81318f19ca57d37fed08c70f70146bfc3e0e58b7c", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/tests/expected.json": "294c6ad7cc0064fc1d681c664b94ccb89c69e9ba3e512d28b61cdd68cfa1ac32", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/tests/scenario/episode.yaml": "f27a4805329b99f79e7db5fbf4ff05a7fe08acd80ca6e06281fa1c1775993a11", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/tests/scenario/notes.md": "10b9f8c369d382dc97ebae40b37d8d5c67184478a0623bdd8a06eab7c43676b8", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/tests/scenario/record.json": "c20f70dcf16f62e2c932aca40fbf3ef588e405709bb0a02d3b40c1858173c165", @@ -8500,19 +8504,19 @@ "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/docker-compose.yaml": "ba2fecdd100f896a66287977de91ee9707501900850420eed78e29d128e907f8", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/team/scenario/episode.yaml": "f27a4805329b99f79e7db5fbf4ff05a7fe08acd80ca6e06281fa1c1775993a11", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/team/scenario/notes.md": "10b9f8c369d382dc97ebae40b37d8d5c67184478a0623bdd8a06eab7c43676b8", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/team/scenario/record.json": "c20f70dcf16f62e2c932aca40fbf3ef588e405709bb0a02d3b40c1858173c165", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/team/scenario/source.md": "7d0db3c69288559cfb84e9a79febe72a9b88cf55a7289c5d83847e63e14ff181", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/team/task.json": "3c5292c34b5d7154d63f45614fa468ecc75953506dc66afb271396efb305bc7c", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/team/task.json": "8157d11e14705217d81a87604ff1fb0ae05a044a40f32d47b9611c548ba4c921", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8525,13 +8529,13 @@ "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/task.toml": "41d797b6b5eba68b1b9b601c3c270217764c560476ba948a3ba3d4db616d7bc5", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/task.toml": "2d4ccc43ea8d956118c309d9cbce5b3056d572370d373828d20823abfa33bb7c", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/tests/expected.json": "d8b288db29ed9fbae178a6b04e8d02b0efd7e6d00e4418946c5c6d76778fbffc", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/tests/scenario/episode.yaml": "f27a4805329b99f79e7db5fbf4ff05a7fe08acd80ca6e06281fa1c1775993a11", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/tests/scenario/notes.md": "10b9f8c369d382dc97ebae40b37d8d5c67184478a0623bdd8a06eab7c43676b8", "tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/tests/scenario/record.json": "c20f70dcf16f62e2c932aca40fbf3ef588e405709bb0a02d3b40c1858173c165", @@ -8550,19 +8554,19 @@ "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/docker-compose.yaml": "fe4ab50fd7df02a9be953ec09c762472f1a5c6ac96a751c169568864aa308202", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/team/scenario/episode.yaml": "dc20b51d5ba478dc841bbc38fc5a093945c04041ec95549af745a418093aea14", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/team/scenario/notes.md": "2e023de99d6afe8b7f8c9a58d07192bb2d0ca7ade78cf03f41f5bcb005e16dd6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/team/scenario/record.json": "924cbeef2f5f2319f2a3154482c359e1bc55e248c6d2d192a066e1b54802423c", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/team/scenario/source.md": "57a757b174ed6fdf59367c300e9c2da682500f08e398f9b0a808b68661df97d3", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/team/task.json": "60ca98ab974e78b9146eb61d9a1cc9c4cd52c529d2b01e3f9abd1fe6d5cbea69", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/team/task.json": "f5cb1ab3843f48921e023f3c7fad73174aa4d534d98dd2739856ea3dd782bdf3", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8575,13 +8579,13 @@ "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/task.toml": "36a5f53a008947d979bac9640e04eb6564b0f0ce82ee2a21e85b53b7d67e4a61", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/task.toml": "6e706b9afdf75f9fab9a6557c122dfca056528aac9012c2095815ac3e7128173", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/tests/expected.json": "5da8ce3bea8addae94f45e68fea3a18b1abe81dc4c2be0a75ba3946534e9531a", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/tests/scenario/episode.yaml": "dc20b51d5ba478dc841bbc38fc5a093945c04041ec95549af745a418093aea14", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/tests/scenario/notes.md": "2e023de99d6afe8b7f8c9a58d07192bb2d0ca7ade78cf03f41f5bcb005e16dd6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/tests/scenario/record.json": "924cbeef2f5f2319f2a3154482c359e1bc55e248c6d2d192a066e1b54802423c", @@ -8600,19 +8604,19 @@ "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/docker-compose.yaml": "def20c47f5118f1c478f4137aca545edc54b335a933d7ad157c8ea771fc20276", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/team/scenario/episode.yaml": "ef77b2cf7031dbb005699ebb43f6ae99f189ab9614982999616d7831e096210f", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/team/scenario/notes.md": "ee6573b9419eb3d5859757e34b43b6bbb2a1b1020d897c8dd591bdb42c73c72b", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/team/scenario/record.json": "9fa3c7030258ac3cf6948658efab9dcbe805e91bce8e24c3611cf8767ed492de", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/team/scenario/source.md": "247c5055176c39bdbbb4979d6b7336f098a437aa2927bf32b652ff40fa80d4f4", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/team/task.json": "a8bd7a8d79cfc614b8fa693c389679106abb17479285df0a8949d647d576c44b", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/team/task.json": "9daf9a18fe162198302203b1290487e9c49169b70256f57a2c5405af27673875", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8625,13 +8629,13 @@ "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/task.toml": "a7fae65449c5626c1267ab00f9219aa6bec749c273ea311ffd2cb4cd428ed870", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/task.toml": "d2e744affe0393c6959aedaf01278fa8cdb7b9a066a293435a03b4f29eb5f82a", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/tests/expected.json": "0752c1e5a1a3ecf93968a79dff46ea6e0a313840e0c3caa6ebe74013e4ed230f", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/tests/scenario/episode.yaml": "ef77b2cf7031dbb005699ebb43f6ae99f189ab9614982999616d7831e096210f", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/tests/scenario/notes.md": "ee6573b9419eb3d5859757e34b43b6bbb2a1b1020d897c8dd591bdb42c73c72b", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/tests/scenario/record.json": "9fa3c7030258ac3cf6948658efab9dcbe805e91bce8e24c3611cf8767ed492de", @@ -8650,19 +8654,19 @@ "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/docker-compose.yaml": "d5f834f1a63338708cd7b13dabee0b5b5dc1a20b4166aee89e43ce3bdf3e3d83", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/team/scenario/episode.yaml": "dc20b51d5ba478dc841bbc38fc5a093945c04041ec95549af745a418093aea14", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/team/scenario/notes.md": "2e023de99d6afe8b7f8c9a58d07192bb2d0ca7ade78cf03f41f5bcb005e16dd6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/team/scenario/record.json": "924cbeef2f5f2319f2a3154482c359e1bc55e248c6d2d192a066e1b54802423c", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/team/scenario/source.md": "57a757b174ed6fdf59367c300e9c2da682500f08e398f9b0a808b68661df97d3", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/team/task.json": "9e8997760b29d70d572ddb3721565e1d188738e53741f787cac1507a29f2679c", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/team/task.json": "c9d3358df0b32552dd32f5129cff3314e98068ed92f7884bae8f54a978d60b0b", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8675,13 +8679,13 @@ "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/task.toml": "5c29205e94d4770d81d76e52b9320b787cab0a10d0b93d3479315bcbaf7831be", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/task.toml": "58351425c1afb7fd28e03676a192c623157f8529cc5ed10517a4a4aa8ffbd969", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/tests/expected.json": "09715f35431f395cc6ea5615a22a5c9a0b5464e8013497abb4551f7dd3c8a660", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/tests/scenario/episode.yaml": "dc20b51d5ba478dc841bbc38fc5a093945c04041ec95549af745a418093aea14", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/tests/scenario/notes.md": "2e023de99d6afe8b7f8c9a58d07192bb2d0ca7ade78cf03f41f5bcb005e16dd6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/tests/scenario/record.json": "924cbeef2f5f2319f2a3154482c359e1bc55e248c6d2d192a066e1b54802423c", @@ -8700,19 +8704,19 @@ "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/docker-compose.yaml": "2c506353dff3fae83fc1497168d87dc476a49de65f228cffee8bd0e15970281d", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/team/scenario/episode.yaml": "dc20b51d5ba478dc841bbc38fc5a093945c04041ec95549af745a418093aea14", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/team/scenario/notes.md": "2e023de99d6afe8b7f8c9a58d07192bb2d0ca7ade78cf03f41f5bcb005e16dd6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/team/scenario/record.json": "924cbeef2f5f2319f2a3154482c359e1bc55e248c6d2d192a066e1b54802423c", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/team/scenario/source.md": "57a757b174ed6fdf59367c300e9c2da682500f08e398f9b0a808b68661df97d3", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/team/task.json": "fffb98e08ea917bb8e358d36865715caa7be7bbf8266aa062c2557cab503af29", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/team/task.json": "dde68b4c42b1331477091ccb3fe6a74cdba6cbf1a3347e56ac1c9ed70cfb924a", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8725,13 +8729,13 @@ "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/task.toml": "9e2f4df048edbadfec8d242a824410a377932fb6024bda9a809eaba5e3f66c91", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/task.toml": "1491b1915338e4fcdcca6a13c44ef8d5efe4ffcc2aa3ed48c301f9a38f9781d1", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/tests/expected.json": "eeab736a670d606c5b44c04c62e7f5647b2321610e32dece76500e2507bffee2", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/tests/scenario/episode.yaml": "dc20b51d5ba478dc841bbc38fc5a093945c04041ec95549af745a418093aea14", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/tests/scenario/notes.md": "2e023de99d6afe8b7f8c9a58d07192bb2d0ca7ade78cf03f41f5bcb005e16dd6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/tests/scenario/record.json": "924cbeef2f5f2319f2a3154482c359e1bc55e248c6d2d192a066e1b54802423c", @@ -8750,19 +8754,19 @@ "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/docker-compose.yaml": "96c374e257a5ac48bbba1fef29023e42828ddaa6459819bce7c7886eef27e2d7", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/team/scenario/episode.yaml": "dc20b51d5ba478dc841bbc38fc5a093945c04041ec95549af745a418093aea14", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/team/scenario/notes.md": "2e023de99d6afe8b7f8c9a58d07192bb2d0ca7ade78cf03f41f5bcb005e16dd6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/team/scenario/record.json": "924cbeef2f5f2319f2a3154482c359e1bc55e248c6d2d192a066e1b54802423c", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/team/scenario/source.md": "57a757b174ed6fdf59367c300e9c2da682500f08e398f9b0a808b68661df97d3", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/team/task.json": "aaf4b8220e1fbf2d8041e9f9109f4b88d490ed47bd1ca49f1c99ea7cddc6917c", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/team/task.json": "aa02bedddecd05f4d344341485642bbf72c73c2fd1b19c5ab9ec6398c35e70a9", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8775,13 +8779,13 @@ "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/task.toml": "783a21b3243131217fd7e1919abfb3fa9448b5b4a18b36b64d363f86d47bf0d6", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/task.toml": "141ffd1d2f20fa40ec145418a639157868d22753ca309981a85b06097181a863", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/tests/expected.json": "d71bbc057574b24c0d132e7a34e872add8d50cb5e4c5d9edd38f234feeae7764", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/tests/scenario/episode.yaml": "dc20b51d5ba478dc841bbc38fc5a093945c04041ec95549af745a418093aea14", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/tests/scenario/notes.md": "2e023de99d6afe8b7f8c9a58d07192bb2d0ca7ade78cf03f41f5bcb005e16dd6", "tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/tests/scenario/record.json": "924cbeef2f5f2319f2a3154482c359e1bc55e248c6d2d192a066e1b54802423c", @@ -8800,19 +8804,19 @@ "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/docker-compose.yaml": "cdab003095cd762c46cf472f7c42a332688690822e1d745222a82ac064eb846f", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/team/scenario/episode.yaml": "015666bc8057fc5a01653f44e36d87a3a78ad726aa2036959d8324e98bd0a486", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/team/scenario/notes.md": "84fe109b5f31a3f1e2a5b894da8d194213102f1c1a383a876b86a730478f61e7", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/team/scenario/record.json": "ec1a77255e9e75359d10cfb39edc990e9f3f2613cf56e73914fff6699c8c4585", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/team/scenario/source.md": "619d7c3d1bd7d8e5d8ac382ab39cba5cd4db73a00fb698848300ba20b01d884c", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/team/task.json": "8c01b30426999ee43b13a047c6b2d2a34b3f315346f10d93f7242b7ba1337a19", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/team/task.json": "a87c5a066d0f08cf0cb931bb771d72e7c50b92feed9659db17c95455614b77ed", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8825,13 +8829,13 @@ "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/task.toml": "1bccf21ca11fad9731a162034ffed1b310e70b8f9e109fae9bec97e955974eba", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/task.toml": "5de35a4e1da0d8d73ef9c13bab31ba16ea7cc9877865fcf42e6e64e1f401748c", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/tests/expected.json": "a9d171e105307ef990ff454a3b9f9362083ccebd2c97ab3d209b4a52ce92fad4", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/tests/scenario/episode.yaml": "015666bc8057fc5a01653f44e36d87a3a78ad726aa2036959d8324e98bd0a486", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/tests/scenario/notes.md": "84fe109b5f31a3f1e2a5b894da8d194213102f1c1a383a876b86a730478f61e7", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/tests/scenario/record.json": "ec1a77255e9e75359d10cfb39edc990e9f3f2613cf56e73914fff6699c8c4585", @@ -8850,19 +8854,19 @@ "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/docker-compose.yaml": "b59b7f61c3a7de5e62572fa0194d2299507ab7f4d05ca36275420ff3622f42a4", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/team/scenario/episode.yaml": "077882737bcdf30520ba7743a2b6bb7b0c3e74d397780082bf0b0cfc65512ead", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/team/scenario/notes.md": "3e0393f9f0b4c7f84a1cd4d27190c5265d61739964e8d7f7a834a4343b0fb634", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/team/scenario/record.json": "2e4ef676c14e4d11848b261753f6fae64052d3456cbdd937b3cdddccc7c00bdc", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/team/scenario/source.md": "5e575c19ecd26435457ef66c25c4883b4f3982d61c950dc608ca6ea43c9773e6", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/team/task.json": "1468ef5314b7f11e2386a7423178cff31bc6397ef031afdc8ba578562abedbc7", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/team/task.json": "367694180f36e031df591a9f2b6167574b3b3da78beb9d918704d07da1eb86f3", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8875,13 +8879,13 @@ "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/task.toml": "982e45529f29e628e52a3104556926fbfff2ff5a29ef88ec2d41971832e0b7ac", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/task.toml": "a822b26523e5a6771c6cf57df2079c880818817ff15275eb85ba0da8c656e9a0", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/tests/expected.json": "67653b37b0411dc806b43a809a5c9b3f046d1e982038b6966f62557bf3090c80", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/tests/scenario/episode.yaml": "077882737bcdf30520ba7743a2b6bb7b0c3e74d397780082bf0b0cfc65512ead", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/tests/scenario/notes.md": "3e0393f9f0b4c7f84a1cd4d27190c5265d61739964e8d7f7a834a4343b0fb634", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/tests/scenario/record.json": "2e4ef676c14e4d11848b261753f6fae64052d3456cbdd937b3cdddccc7c00bdc", @@ -8900,19 +8904,19 @@ "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/docker-compose.yaml": "edb83107d2b9841623230dee973d47de91eb325dac8e7c612a4e804d72eba42a", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/team/scenario/episode.yaml": "015666bc8057fc5a01653f44e36d87a3a78ad726aa2036959d8324e98bd0a486", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/team/scenario/notes.md": "84fe109b5f31a3f1e2a5b894da8d194213102f1c1a383a876b86a730478f61e7", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/team/scenario/record.json": "ec1a77255e9e75359d10cfb39edc990e9f3f2613cf56e73914fff6699c8c4585", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/team/scenario/source.md": "619d7c3d1bd7d8e5d8ac382ab39cba5cd4db73a00fb698848300ba20b01d884c", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/team/task.json": "85a6861af8b20d946e28236122e3437c682bd2b44fe74cc72f03712536827074", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/team/task.json": "e307b70b362ffdcca64425277356ea1093e531e95a045e027b3183afa9fe56ac", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8925,13 +8929,13 @@ "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/task.toml": "a6472bf7e7236ad535500d418e7677797401e831f177b1189f15ab6c70fab067", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/task.toml": "2335d16e8c735dbf1462fcc26d803db1c7bdded0b8fa5db37afa5314b95d77de", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/tests/expected.json": "4414f352318d851cb62382057569dd110ee4c229c66df960ed1539812a74f3d8", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/tests/scenario/episode.yaml": "015666bc8057fc5a01653f44e36d87a3a78ad726aa2036959d8324e98bd0a486", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/tests/scenario/notes.md": "84fe109b5f31a3f1e2a5b894da8d194213102f1c1a383a876b86a730478f61e7", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/tests/scenario/record.json": "ec1a77255e9e75359d10cfb39edc990e9f3f2613cf56e73914fff6699c8c4585", @@ -8950,19 +8954,19 @@ "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/docker-compose.yaml": "8157163a94ea1551a785559543aa36f45fd0077aafa5b2cf9e0df3fa43f3fd7d", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/team/scenario/episode.yaml": "015666bc8057fc5a01653f44e36d87a3a78ad726aa2036959d8324e98bd0a486", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/team/scenario/notes.md": "84fe109b5f31a3f1e2a5b894da8d194213102f1c1a383a876b86a730478f61e7", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/team/scenario/record.json": "ec1a77255e9e75359d10cfb39edc990e9f3f2613cf56e73914fff6699c8c4585", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/team/scenario/source.md": "619d7c3d1bd7d8e5d8ac382ab39cba5cd4db73a00fb698848300ba20b01d884c", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/team/task.json": "6f8019bfb06140493b231061a4cacd558737f3c67efa8038e22a3ffe863d4e7c", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/team/task.json": "010c3cb5d075a0b80aea49b6d0ef83b62d76cd2464dee717b70128ea28902d6c", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -8975,13 +8979,13 @@ "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/task.toml": "cfa6c5f8f85a2c94e7aa0daf9902a8f9d62e97fdb71215f708211e76f532880b", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/task.toml": "6a7decc51fd04ca19df4d8094ad710d2b80db6223b6945604c192d1eb3c0a119", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/tests/expected.json": "1e38a7c5e614676eca6d63b3b97365011fd09c37a8cd9be5e8eb783e6cbacb62", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/tests/scenario/episode.yaml": "015666bc8057fc5a01653f44e36d87a3a78ad726aa2036959d8324e98bd0a486", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/tests/scenario/notes.md": "84fe109b5f31a3f1e2a5b894da8d194213102f1c1a383a876b86a730478f61e7", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/tests/scenario/record.json": "ec1a77255e9e75359d10cfb39edc990e9f3f2613cf56e73914fff6699c8c4585", @@ -9000,19 +9004,19 @@ "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/docker-compose.yaml": "146816d759285454077ba8d6ab348cb68624f4d345b4b0bbf60cdc258c570d36", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/team/scenario/episode.yaml": "015666bc8057fc5a01653f44e36d87a3a78ad726aa2036959d8324e98bd0a486", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/team/scenario/notes.md": "84fe109b5f31a3f1e2a5b894da8d194213102f1c1a383a876b86a730478f61e7", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/team/scenario/record.json": "ec1a77255e9e75359d10cfb39edc990e9f3f2613cf56e73914fff6699c8c4585", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/team/scenario/source.md": "619d7c3d1bd7d8e5d8ac382ab39cba5cd4db73a00fb698848300ba20b01d884c", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/team/task.json": "a624413e5474f3bf14750f426de6bb8625d29f8942b7267d66133c72083c06ae", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/team/task.json": "5f5831f95578d8e40ffaadcac691291187ea1005e074e9345c3b228ab1d6b494", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9025,13 +9029,13 @@ "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/task.toml": "de469986972e09e17a4b6e4899ea7660227cc06b53e0f7c16d7ddf395f105949", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/task.toml": "abed8e47b5d8d56e9f6d5afee89af43f6f10be64c4f4c422447fc34c9a97311c", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/tests/expected.json": "f7fd0bc565cdf1db6350f11c2ff1f6435358a5b51aeea95b340527d02fd5f971", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/tests/scenario/episode.yaml": "015666bc8057fc5a01653f44e36d87a3a78ad726aa2036959d8324e98bd0a486", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/tests/scenario/notes.md": "84fe109b5f31a3f1e2a5b894da8d194213102f1c1a383a876b86a730478f61e7", "tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/tests/scenario/record.json": "ec1a77255e9e75359d10cfb39edc990e9f3f2613cf56e73914fff6699c8c4585", @@ -9050,19 +9054,19 @@ "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/docker-compose.yaml": "c4f72daad1ff5891332924ef93c6b382b1c03a129b9a3cffff543f63aa515b5d", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/team/scenario/episode.yaml": "278f95443d0f6d6014ab5bf7cbbdf2a123a0ea66f7c65da2349b514335bb8de6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/team/scenario/notes.md": "c554a936184fc54833b56bcca3f3af7fcf269a2c80305b796eafb27369640da0", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/team/scenario/record.json": "8ec62d9881792e507ec90b3315fa5803ef27ebabce3a0aadbcc1a0da0ef02cd7", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/team/scenario/source.md": "b54c32bfa1b21bccc78114ff0f56d5bf638f0d8ac4a80d7bd199a526b15efc71", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/team/task.json": "cbc3ebd23a35d6e2e480e9e8dc469f56376cc90e1f071c40feeea26af25a968c", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/team/task.json": "a57f8f5de2a09f6624b86ceb0d2ed85fb48f324d0b31f359d7be383af90a98eb", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9075,13 +9079,13 @@ "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/task.toml": "eabebac83fb7627a9735b6b652f90758a1fed7fdfb460c60c69b2e767c3872df", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/task.toml": "2216aee376bde80fffabcebf86617e4ef7729a15ede36d561dbb48dad194227f", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/tests/expected.json": "8e7c91ad5c202553d6f8b6130d77f9f9e22b9fc3ff392dab465da8fc0c3752d5", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/tests/scenario/episode.yaml": "278f95443d0f6d6014ab5bf7cbbdf2a123a0ea66f7c65da2349b514335bb8de6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/tests/scenario/notes.md": "c554a936184fc54833b56bcca3f3af7fcf269a2c80305b796eafb27369640da0", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/tests/scenario/record.json": "8ec62d9881792e507ec90b3315fa5803ef27ebabce3a0aadbcc1a0da0ef02cd7", @@ -9100,19 +9104,19 @@ "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/docker-compose.yaml": "1a84862f6eda4ee4decc85dc435879cb60f451871c7f43dc50acd64847f68c09", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/team/scenario/episode.yaml": "28fbf6b69c240ee71f5668fca5182e04cf672e3f2a645abdc53b52badbdf7020", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/team/scenario/notes.md": "e4b92c6e981830c12997a4f8fd64c1b76e830bde35f2b2fbf8851da01f3c360c", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/team/scenario/record.json": "7bec08f476053592ee2f0e9b6a6a110f7f13d0ded2c997ea09951d93b6652263", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/team/scenario/source.md": "65154cf2fab1dde390a142db6b1c15cf9ac9f3067bca15e50a97961d496a569f", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/team/task.json": "2091fcc78f052b0eb2eea7c56c16887c6f6296e5b8fdef05ced6de82ee13f9f5", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/team/task.json": "4dec0c4d9b150bfe481c6d622803bd93cc87c9c8b7e8feedeb5e88dfd580e2ff", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9125,13 +9129,13 @@ "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/task.toml": "e40d3d9f40e882730f829b1931de6860f2c2cd145ae23cfffe1abf20d5e4d2a8", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/task.toml": "98465df219f7a28ad74aa41f8bcb5495aea1966b1b75b9ec8edeef4be193311e", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/tests/expected.json": "9d0693c9ba510f494c4bd270b1eb8f852e91cbedc48a733aa7ba787bea040a62", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/tests/scenario/episode.yaml": "28fbf6b69c240ee71f5668fca5182e04cf672e3f2a645abdc53b52badbdf7020", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/tests/scenario/notes.md": "e4b92c6e981830c12997a4f8fd64c1b76e830bde35f2b2fbf8851da01f3c360c", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/tests/scenario/record.json": "7bec08f476053592ee2f0e9b6a6a110f7f13d0ded2c997ea09951d93b6652263", @@ -9150,19 +9154,19 @@ "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/docker-compose.yaml": "8bb52a30dba7486d3461dc2e1dd7b528fb84a2f83914584e00edc0f9d47a05af", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/team/scenario/episode.yaml": "278f95443d0f6d6014ab5bf7cbbdf2a123a0ea66f7c65da2349b514335bb8de6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/team/scenario/notes.md": "c554a936184fc54833b56bcca3f3af7fcf269a2c80305b796eafb27369640da0", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/team/scenario/record.json": "8ec62d9881792e507ec90b3315fa5803ef27ebabce3a0aadbcc1a0da0ef02cd7", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/team/scenario/source.md": "b54c32bfa1b21bccc78114ff0f56d5bf638f0d8ac4a80d7bd199a526b15efc71", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/team/task.json": "03f8ae862a6486f10e6a19eded992eb797adcb08a4bb3d8641a6196e9ae52bfe", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/team/task.json": "9deb97662fdf2af34456b540d3126911fa8a4d1093bf97f91b97d9989e326349", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9175,13 +9179,13 @@ "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/task.toml": "73e317f82caae416732da2ac7ee6012749507cb7936976a64d9efea642cd30c5", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/task.toml": "bf3304c24b581c55b46ad8f563593d9511dbb68de7adbb17a48d1fd00ac94c47", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/tests/expected.json": "5c03c7c817c64383a11e19c37f583a13293bf9f61cc8592d75718c9a453535f5", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/tests/scenario/episode.yaml": "278f95443d0f6d6014ab5bf7cbbdf2a123a0ea66f7c65da2349b514335bb8de6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/tests/scenario/notes.md": "c554a936184fc54833b56bcca3f3af7fcf269a2c80305b796eafb27369640da0", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/tests/scenario/record.json": "8ec62d9881792e507ec90b3315fa5803ef27ebabce3a0aadbcc1a0da0ef02cd7", @@ -9200,19 +9204,19 @@ "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/docker-compose.yaml": "809d7c28ea7e61f1c880a6dcdd66506c175ea5672418831d75a6fbc6204d028b", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/team/scenario/episode.yaml": "278f95443d0f6d6014ab5bf7cbbdf2a123a0ea66f7c65da2349b514335bb8de6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/team/scenario/notes.md": "c554a936184fc54833b56bcca3f3af7fcf269a2c80305b796eafb27369640da0", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/team/scenario/record.json": "8ec62d9881792e507ec90b3315fa5803ef27ebabce3a0aadbcc1a0da0ef02cd7", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/team/scenario/source.md": "b54c32bfa1b21bccc78114ff0f56d5bf638f0d8ac4a80d7bd199a526b15efc71", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/team/task.json": "4fd6fc69f1f984a29e430b21ff8537385d53c833455ad979afbf75a23ade1e53", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/team/task.json": "be5442612e3e5af2cb5b7ef45a545833b20e0bf99c393be99cb9263fbc8d30ae", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9225,13 +9229,13 @@ "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/task.toml": "99ea7ff78334b136d9f72136621447f361c5bcd853758154e3d6612e0ae30d09", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/task.toml": "953ec909964484fa2ae86b36723a86ce721929f5acd084a5c1cd06be0ce694e4", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/tests/expected.json": "0453b7cf04c5ab40760fa07194eef96f7e95280dfff28fc6e1866d8486a42e71", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/tests/scenario/episode.yaml": "278f95443d0f6d6014ab5bf7cbbdf2a123a0ea66f7c65da2349b514335bb8de6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/tests/scenario/notes.md": "c554a936184fc54833b56bcca3f3af7fcf269a2c80305b796eafb27369640da0", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/tests/scenario/record.json": "8ec62d9881792e507ec90b3315fa5803ef27ebabce3a0aadbcc1a0da0ef02cd7", @@ -9250,19 +9254,19 @@ "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/docker-compose.yaml": "83e895623672ef3cfd322d057d645fec0220f431ca8e6c9c76cc7bec582c8aaa", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/team/scenario/episode.yaml": "278f95443d0f6d6014ab5bf7cbbdf2a123a0ea66f7c65da2349b514335bb8de6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/team/scenario/notes.md": "c554a936184fc54833b56bcca3f3af7fcf269a2c80305b796eafb27369640da0", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/team/scenario/record.json": "8ec62d9881792e507ec90b3315fa5803ef27ebabce3a0aadbcc1a0da0ef02cd7", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/team/scenario/source.md": "b54c32bfa1b21bccc78114ff0f56d5bf638f0d8ac4a80d7bd199a526b15efc71", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/team/task.json": "ec425b7d9c84eb75eb31875f49876342edf5d46f3d8a21e1dba727c3b3f62cd3", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/team/task.json": "55deff74c36e1242886d853c6c6ce9a6290d5f45ed3768851f83c5a39704b20a", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9275,13 +9279,13 @@ "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/task.toml": "08e17a0e88a4ae89f9ca3028e12ec6ee82fde0b77ff41e174f227c3dc2191bcd", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/task.toml": "fd925790533d7dfa5dc8892a658733a89e8f790529e56bc2f949579ac9160a52", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/tests/expected.json": "29e226c6eab17b1c5dc45420b1bbd76913c02212a8b993aa602e3abef2e22c78", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/tests/scenario/episode.yaml": "278f95443d0f6d6014ab5bf7cbbdf2a123a0ea66f7c65da2349b514335bb8de6", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/tests/scenario/notes.md": "c554a936184fc54833b56bcca3f3af7fcf269a2c80305b796eafb27369640da0", "tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/tests/scenario/record.json": "8ec62d9881792e507ec90b3315fa5803ef27ebabce3a0aadbcc1a0da0ef02cd7", @@ -9300,20 +9304,20 @@ "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/docker-compose.yaml": "20f9bf029e7e1b3d831e7d88936e9e953aa943e86c783237c6f945768dde41d5", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/team/scenario/NOTICE": "333cdb75f6a78126462b303d2a08d9edf7a048d777333b83eac55411d260ef6c", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/team/scenario/episode.yaml": "cbbbd3c8e44518826bc440aacdd40b1d9519b66a38bce1d2590c3a81d25434c9", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/team/scenario/notes.md": "39da8461552efb2878c0a9bec507a3d597d37fe173db3d47b063c3d0f40ecfcc", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/team/scenario/record.json": "66e76fb135ab0a781f4f4b3099b5b383fd69ad946bfc267622b2227d2f57c625", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/team/scenario/source.md": "6a2b3ed5b7db1234b876017509bced1b025688e5301d5dca233e5880fb09d5eb", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/team/task.json": "4babe9a71a4054e782ca11cb5ac2f5625edcf51ca40be4990ff5c73842986b65", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/team/task.json": "9192914a768aa7f71d6ca715557ce4f0fb9275696b8a2170da58f57335f75342", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9326,13 +9330,13 @@ "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/task.toml": "378ad888b553efbefea655c2e45db6f0977f3233d40d416406edf4264fe16568", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/task.toml": "4dbcde2d3c61b0911c294bca1b7601a8bab9317b90c5b822e9017d2790425086", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/tests/expected.json": "2d3869f58f53c2e6271c3cda584e4a15e7b35d11e0f79d77696ae9c691a688ae", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/tests/scenario/NOTICE": "333cdb75f6a78126462b303d2a08d9edf7a048d777333b83eac55411d260ef6c", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/tests/scenario/episode.yaml": "cbbbd3c8e44518826bc440aacdd40b1d9519b66a38bce1d2590c3a81d25434c9", "tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/tests/scenario/notes.md": "39da8461552efb2878c0a9bec507a3d597d37fe173db3d47b063c3d0f40ecfcc", @@ -9352,20 +9356,20 @@ "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/docker-compose.yaml": "a05560c00c9efbc4a364b45926659025d9718f166eb3bbfd0c1288bcce4b605c", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/team/scenario/NOTICE": "333cdb75f6a78126462b303d2a08d9edf7a048d777333b83eac55411d260ef6c", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/team/scenario/episode.yaml": "3a42c7a19f6227173496c4cd0d6cdcd44a036488a598dd5e47372f474f4412f8", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/team/scenario/notes.md": "e59e92edb172e64b55f746773a8913d14c7f5594be7867639c2557e0066ae45c", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/team/scenario/record.json": "b31a2ef51d2534a46dd3079f4478f12df660ee1d405b0287b4165e78b8a3b2be", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/team/scenario/source.md": "fdb8c0e21ba326a3d019c80ec7656df287d67484933b18929e25ec13cf915cfc", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/team/task.json": "5e36d8037d3d60f8f1296366a3864d86439668a80d4e0f87a3133046b4893c8c", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/team/task.json": "d31c0359a51d67bd11954889755b6f9e23ec61debfae1ddd29f752dba35de13f", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9378,13 +9382,13 @@ "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/task.toml": "9ea78bd53c574f0e5a98d1f210ac52904c39f06a129ecb923be140d7ac5bf1c4", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/task.toml": "0642dfa790b5ceac854b11030be94aa6ccd4d929776fa1aba96dd766c85c0ec0", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/tests/expected.json": "9f5d21d6c9c3d6d82760bd989ebbf440baf2a7768c6a3984f370c466323f8552", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/tests/scenario/NOTICE": "333cdb75f6a78126462b303d2a08d9edf7a048d777333b83eac55411d260ef6c", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/tests/scenario/episode.yaml": "3a42c7a19f6227173496c4cd0d6cdcd44a036488a598dd5e47372f474f4412f8", "tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/tests/scenario/notes.md": "e59e92edb172e64b55f746773a8913d14c7f5594be7867639c2557e0066ae45c", @@ -9404,20 +9408,20 @@ "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/docker-compose.yaml": "07fed75755cac58be0e48144efd8f6d3f2d5ec48003b30c879d8f17aa3763f99", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/team/scenario/NOTICE": "333cdb75f6a78126462b303d2a08d9edf7a048d777333b83eac55411d260ef6c", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/team/scenario/episode.yaml": "cbbbd3c8e44518826bc440aacdd40b1d9519b66a38bce1d2590c3a81d25434c9", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/team/scenario/notes.md": "39da8461552efb2878c0a9bec507a3d597d37fe173db3d47b063c3d0f40ecfcc", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/team/scenario/record.json": "66e76fb135ab0a781f4f4b3099b5b383fd69ad946bfc267622b2227d2f57c625", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/team/scenario/source.md": "6a2b3ed5b7db1234b876017509bced1b025688e5301d5dca233e5880fb09d5eb", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/team/task.json": "63078a14ae52e1e40549347f297052d344d28126bf656858ee5d175f175ccee4", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/team/task.json": "d45b165503db8422daa4470c6512e756a3f9c988e61f4b6592e6cd37468ef248", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9430,13 +9434,13 @@ "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/task.toml": "3d6520402a8178a0b93521248bb4025e9f24904c30dae1278b2ba5637deafa23", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/task.toml": "fe9dc3ec3e45fd47c9f6ebdc193dfa1c1052deec58208a080c5fbb9197da8b43", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/tests/expected.json": "409da97be5fe593c1af40d24daf0b0ce5cda279a45de7588ab427460c6989723", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/tests/scenario/NOTICE": "333cdb75f6a78126462b303d2a08d9edf7a048d777333b83eac55411d260ef6c", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/tests/scenario/episode.yaml": "cbbbd3c8e44518826bc440aacdd40b1d9519b66a38bce1d2590c3a81d25434c9", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/tests/scenario/notes.md": "39da8461552efb2878c0a9bec507a3d597d37fe173db3d47b063c3d0f40ecfcc", @@ -9456,20 +9460,20 @@ "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/docker-compose.yaml": "38837648c2dea7ee0c7320b0e314f455310f1210a94a39c221d55519f46f0b9f", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/team/scenario/NOTICE": "333cdb75f6a78126462b303d2a08d9edf7a048d777333b83eac55411d260ef6c", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/team/scenario/episode.yaml": "cbbbd3c8e44518826bc440aacdd40b1d9519b66a38bce1d2590c3a81d25434c9", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/team/scenario/notes.md": "39da8461552efb2878c0a9bec507a3d597d37fe173db3d47b063c3d0f40ecfcc", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/team/scenario/record.json": "66e76fb135ab0a781f4f4b3099b5b383fd69ad946bfc267622b2227d2f57c625", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/team/scenario/source.md": "6a2b3ed5b7db1234b876017509bced1b025688e5301d5dca233e5880fb09d5eb", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/team/task.json": "c931d1dc93be3e10087760b7f1b1e7bf6471edf1501745943071cf28584b4083", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/team/task.json": "1179603bbf2803ec542dd5c20171c6f037687fe5cde965f159a6fa1c5f425e03", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9482,13 +9486,13 @@ "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/task.toml": "b09bcdaa313db50fff95ba2fda758604e47e9c751a1ee7f3d57236a102d58a93", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/task.toml": "18747fc2866abbc928496c7a35254f3c2fa68e2c1943804a2daf1e71538d6502", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/tests/expected.json": "a2cc7a5e1c3e82ab920d8f3f842d32d53ec82f9c0727c2d26f841b06914f4de9", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/tests/scenario/NOTICE": "333cdb75f6a78126462b303d2a08d9edf7a048d777333b83eac55411d260ef6c", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/tests/scenario/episode.yaml": "cbbbd3c8e44518826bc440aacdd40b1d9519b66a38bce1d2590c3a81d25434c9", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/tests/scenario/notes.md": "39da8461552efb2878c0a9bec507a3d597d37fe173db3d47b063c3d0f40ecfcc", @@ -9508,20 +9512,20 @@ "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/docker-compose.yaml": "7c1d353baa99e05a0baf7211af7ff73aaaffb0131e3a11bdab7dd49ce9f84e77", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/team/scenario/NOTICE": "333cdb75f6a78126462b303d2a08d9edf7a048d777333b83eac55411d260ef6c", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/team/scenario/episode.yaml": "cbbbd3c8e44518826bc440aacdd40b1d9519b66a38bce1d2590c3a81d25434c9", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/team/scenario/notes.md": "39da8461552efb2878c0a9bec507a3d597d37fe173db3d47b063c3d0f40ecfcc", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/team/scenario/record.json": "66e76fb135ab0a781f4f4b3099b5b383fd69ad946bfc267622b2227d2f57c625", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/team/scenario/source.md": "6a2b3ed5b7db1234b876017509bced1b025688e5301d5dca233e5880fb09d5eb", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/team/task.json": "0734adb4dfbc1d57b0784bb79739f8cdf8796a0d3ba3399d3241541fa472c4d7", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/team/task.json": "969cc00ac7ba93785fe75c5a293367fa9cd1fce0741059ecb99d42b7af348c8f", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9534,13 +9538,13 @@ "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/task.toml": "23692c8ffd00ccb7071f1057879de9066a874a640a157fe194f0443e879cd46f", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/task.toml": "92c32280e82f382944b2811cc50446753fa7dd8ca99031b9c6321c023ad34ea8", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/tests/expected.json": "c093a67318e8b7310910b47fe5fbfc0c4b1d1af23a7f5904a421579f4c3676c5", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/tests/scenario/NOTICE": "333cdb75f6a78126462b303d2a08d9edf7a048d777333b83eac55411d260ef6c", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/tests/scenario/episode.yaml": "cbbbd3c8e44518826bc440aacdd40b1d9519b66a38bce1d2590c3a81d25434c9", "tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/tests/scenario/notes.md": "39da8461552efb2878c0a9bec507a3d597d37fe173db3d47b063c3d0f40ecfcc", @@ -9560,20 +9564,20 @@ "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/docker-compose.yaml": "13f384e3a916ef51a416f39e9a05300b42e9ab7e699720c106f939638ed5104a", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/team/scenario/NOTICE": "43c1674a989712ca12e790e9157885b47f4e385a95bf1cd2e0407c2cad2d80ad", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/team/scenario/episode.yaml": "1aa28b657f4cd99edf64261320fc37fc3e1db292d6a0d5debc28d747264b8e49", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/team/scenario/notes.md": "782ff81644dd358e4f3a40fcf1edc20bd50a5caa01b80384d6bdf790431928d5", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/team/scenario/record.json": "7faa58ae1e08454012785061280141b1d5d725f22d389597758d471ede4817cd", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/team/scenario/source.md": "c302a1997622154ba42184c287a169d1d85deff4fece942725227cf7627ba218", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/team/task.json": "76c2ee62b6b80613a5d82119d21f96cb856f4e856480fe6362e8a14bd446cfaf", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/team/task.json": "af9b8eeada1f107af1f277ff3482bb9a91f67d18eb783f907d4080316c81ed2b", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9586,13 +9590,13 @@ "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/task.toml": "60c5ddccf26b6e99ae025430303f573ec0ae197c565653612436ffebe9a9fdfb", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/task.toml": "6f18e2667edc826fe5c6b599adf87626e449e88bf6a69baf5650dd330d9d257a", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/tests/expected.json": "2daceacfb6e192efc66b9656ff4943a0125c259f52bfc426d55d47ea0b61ef75", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/tests/scenario/NOTICE": "43c1674a989712ca12e790e9157885b47f4e385a95bf1cd2e0407c2cad2d80ad", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/tests/scenario/episode.yaml": "1aa28b657f4cd99edf64261320fc37fc3e1db292d6a0d5debc28d747264b8e49", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/tests/scenario/notes.md": "782ff81644dd358e4f3a40fcf1edc20bd50a5caa01b80384d6bdf790431928d5", @@ -9612,20 +9616,20 @@ "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/docker-compose.yaml": "c1447113f070cca0bc52cad0a697ca5ca2fa68f27ce57b55eca83a9e3db79cde", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/team/scenario/NOTICE": "43c1674a989712ca12e790e9157885b47f4e385a95bf1cd2e0407c2cad2d80ad", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/team/scenario/episode.yaml": "c020b071ffd9f70f122027c04de621f308f8ea5df6fab7b3bc6032c09836f69c", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/team/scenario/notes.md": "d30e079ed3cbf349d47173a8827797425b435fb6a4f0eeba8c0820edb45c96c0", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/team/scenario/record.json": "c3baf7d74386f0d91d807e6308668928d80b94a699d9b38941d29a20e3738304", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/team/scenario/source.md": "9b22becae81487bcaa19a6c291aaf97ec4311dc4da05194ffd83429deb243254", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/team/task.json": "e1c77ca3a8a8cfae95bf7a53dead8491d15def307b17f04219da1e1b5085e4ce", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/team/task.json": "3c18addc22d6917d68605ef62da452a0fae4673a5a4ebb9d7e9d116719bd6538", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9638,13 +9642,13 @@ "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/task.toml": "31feffa915cd7c9e620547c25e42f875be6aac117d28a80de49dfb3fd5ab8a2a", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/task.toml": "5a36dce9419805592637467cf8c49e8886af8d5c18782827d4b9cb6598fee994", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/tests/expected.json": "9b49239944f06c3a62c147dace8fa568891d94415d840a3af7f83e327c87a6eb", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/tests/scenario/NOTICE": "43c1674a989712ca12e790e9157885b47f4e385a95bf1cd2e0407c2cad2d80ad", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/tests/scenario/episode.yaml": "c020b071ffd9f70f122027c04de621f308f8ea5df6fab7b3bc6032c09836f69c", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/tests/scenario/notes.md": "d30e079ed3cbf349d47173a8827797425b435fb6a4f0eeba8c0820edb45c96c0", @@ -9664,20 +9668,20 @@ "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/docker-compose.yaml": "db13cb6c45baf6b2d582f8da32185211e4455144786b2c2a0654bea70d7e7449", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/team/scenario/NOTICE": "43c1674a989712ca12e790e9157885b47f4e385a95bf1cd2e0407c2cad2d80ad", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/team/scenario/episode.yaml": "1aa28b657f4cd99edf64261320fc37fc3e1db292d6a0d5debc28d747264b8e49", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/team/scenario/notes.md": "782ff81644dd358e4f3a40fcf1edc20bd50a5caa01b80384d6bdf790431928d5", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/team/scenario/record.json": "7faa58ae1e08454012785061280141b1d5d725f22d389597758d471ede4817cd", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/team/scenario/source.md": "c302a1997622154ba42184c287a169d1d85deff4fece942725227cf7627ba218", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/team/task.json": "dafa5b22ee8a8b32d287c4f6e79f782ea9d2e8ae500bac6f5307747b346182c8", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/team/task.json": "fe9af5d4c2370872ce3e4b832de126c63e2fc5a81cdfd4c1e539b1b292e12947", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9690,13 +9694,13 @@ "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/task.toml": "dbe48cb16447b5124986ad41ece6f18da0866c8d774ca457c462a54123c7a95c", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/task.toml": "88da2769d7ec7007b4a4aade132264ec151bdfc06c22f00fbd206a87c90178c8", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/tests/expected.json": "624c6356a7ffb41df19c371c2d989e13068e7a4e2a672d4f29a55145a39b9fa8", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/tests/scenario/NOTICE": "43c1674a989712ca12e790e9157885b47f4e385a95bf1cd2e0407c2cad2d80ad", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/tests/scenario/episode.yaml": "1aa28b657f4cd99edf64261320fc37fc3e1db292d6a0d5debc28d747264b8e49", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/tests/scenario/notes.md": "782ff81644dd358e4f3a40fcf1edc20bd50a5caa01b80384d6bdf790431928d5", @@ -9716,20 +9720,20 @@ "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/docker-compose.yaml": "98447dbb1aa8f79c8389b18eb1e6bebdf6935cb348cb15ef5c623a242abdb429", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/team/scenario/NOTICE": "43c1674a989712ca12e790e9157885b47f4e385a95bf1cd2e0407c2cad2d80ad", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/team/scenario/episode.yaml": "1aa28b657f4cd99edf64261320fc37fc3e1db292d6a0d5debc28d747264b8e49", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/team/scenario/notes.md": "782ff81644dd358e4f3a40fcf1edc20bd50a5caa01b80384d6bdf790431928d5", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/team/scenario/record.json": "7faa58ae1e08454012785061280141b1d5d725f22d389597758d471ede4817cd", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/team/scenario/source.md": "c302a1997622154ba42184c287a169d1d85deff4fece942725227cf7627ba218", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/team/task.json": "e0203474219737865c71a0c0f240d3b5d78ba678d0096e0fb1da4e5f1556c818", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/team/task.json": "555f2184408d4183c17cc71d247a67ae97b3a5f56e58d86d582b5cf9079817b9", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9742,13 +9746,13 @@ "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/task.toml": "2a18c3f11b18bd7680ac39b1234afd44f8256bc2a4c34a82993092df9f876a45", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/task.toml": "9f8ae5690d5196c34b1dea5faa1e7515e06bffe74a62a1fc799e933752964c02", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/tests/expected.json": "4abadb05f0773305c01103e63b3dcbf521296e8abc88c59a817d652f9327a772", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/tests/scenario/NOTICE": "43c1674a989712ca12e790e9157885b47f4e385a95bf1cd2e0407c2cad2d80ad", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/tests/scenario/episode.yaml": "1aa28b657f4cd99edf64261320fc37fc3e1db292d6a0d5debc28d747264b8e49", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/tests/scenario/notes.md": "782ff81644dd358e4f3a40fcf1edc20bd50a5caa01b80384d6bdf790431928d5", @@ -9768,20 +9772,20 @@ "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/docker-compose.yaml": "cf4c2525cd5f9373baaec282f40a38daab797af9603d31f506741a9089d29e79", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/team/scenario/NOTICE": "43c1674a989712ca12e790e9157885b47f4e385a95bf1cd2e0407c2cad2d80ad", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/team/scenario/episode.yaml": "1aa28b657f4cd99edf64261320fc37fc3e1db292d6a0d5debc28d747264b8e49", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/team/scenario/notes.md": "782ff81644dd358e4f3a40fcf1edc20bd50a5caa01b80384d6bdf790431928d5", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/team/scenario/record.json": "7faa58ae1e08454012785061280141b1d5d725f22d389597758d471ede4817cd", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/team/scenario/source.md": "c302a1997622154ba42184c287a169d1d85deff4fece942725227cf7627ba218", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/team/task.json": "6baca52c73b0cf5067bdf05e158bd9ed482f5e5501eda7302a26e798c07c5e8f", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/team/task.json": "1d113bc66821650f80ec6c1c8a59e6b33913cc13eb051ed6adc687e9fc3a1c3b", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9794,13 +9798,13 @@ "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/task.toml": "354f1c1ae461b81dedc11bf68708233f8fd95714240f2f85536af026e665f64f", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/task.toml": "bc8ca40d93bcf52ab9c99d4eef42609bd907a83bc1d221fcbf9eb18a354e6fb5", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/tests/expected.json": "6cb389491ea6293add2cb7c9cc63b481e2e1453ae8c75a9ff240071616d1c93d", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/tests/scenario/NOTICE": "43c1674a989712ca12e790e9157885b47f4e385a95bf1cd2e0407c2cad2d80ad", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/tests/scenario/episode.yaml": "1aa28b657f4cd99edf64261320fc37fc3e1db292d6a0d5debc28d747264b8e49", "tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/tests/scenario/notes.md": "782ff81644dd358e4f3a40fcf1edc20bd50a5caa01b80384d6bdf790431928d5", @@ -9820,20 +9824,20 @@ "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/docker-compose.yaml": "f335d022218f54579d6bf44367ab2cd8cedfa55c6648308bcc28eedaf572c62c", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/team/scenario/NOTICE": "619007f94808622917a279011bae4ab1a2b52975282f36fae9e471fb43e55508", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/team/scenario/episode.yaml": "08ceaefb9939e759ca96000a52ec38bd095cf6ada74cbe97a420311ebc624e16", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/team/scenario/notes.md": "dae337111b36909746068871f8590ad277cf57f00536edcaab04aa9df4420c86", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/team/scenario/record.json": "d22d12d475cc40f429c25a85eea8e1c6489f5aebdfe8f847cad842b1cbf8e2d3", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/team/scenario/source.md": "bf7adb79608a32e194b1d507829dbd999b1021853f0144325afe28e8e31ab203", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/team/task.json": "6f6117b25621b431811da73b537a0c2321d3ba57ba6e71267a2ee12eba0579fa", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/team/task.json": "ac56ddc7a944cf75e80fd3482851e8b03876c313c4af833c39b0add13b213014", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9846,13 +9850,13 @@ "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/task.toml": "be9f727b892763307cb018ec31a5406d6200a7f9b9a653b46ebe584579b0f3b4", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/task.toml": "bbd168b88b983a7cf81c4d7db1ef88c7c5693fee42539d6b6df7c3b84078cdb6", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/tests/expected.json": "1e09deef966137faa1977e1acad8ada5ad7aaec9c839c19730ba2b182a4114bb", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/tests/scenario/NOTICE": "619007f94808622917a279011bae4ab1a2b52975282f36fae9e471fb43e55508", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/tests/scenario/episode.yaml": "08ceaefb9939e759ca96000a52ec38bd095cf6ada74cbe97a420311ebc624e16", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/tests/scenario/notes.md": "dae337111b36909746068871f8590ad277cf57f00536edcaab04aa9df4420c86", @@ -9872,20 +9876,20 @@ "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/docker-compose.yaml": "da7f151e987e06a1749fd513a65da90d67763b43e0ac6034e94dc3e6819f2451", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/team/scenario/NOTICE": "619007f94808622917a279011bae4ab1a2b52975282f36fae9e471fb43e55508", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/team/scenario/episode.yaml": "1290cfa46263400fdedb50561e432db0d9fc3ecebbdee2bc03ed7825bd2821f2", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/team/scenario/notes.md": "5b7fd07b758678db267cc9368659e33b412bbae1998829a890c86fe0ad370812", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/team/scenario/record.json": "8153d629314966c24f45fc13992a5a956fb47062bbac7c40a8e74a3d7f03624d", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/team/scenario/source.md": "fd59aca3d595933e94485f0e655d9752e8f4cc4af04064bcccb6031eedf11d2a", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/team/task.json": "a24ff335abc026c33e6df8855dbbec176fd31daa74896fdbe42a55368867b457", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/team/task.json": "cef3c5599774054999f387d2bd67e91f0681c3c3906958ddf626a7fa2e18bb94", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9898,13 +9902,13 @@ "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/task.toml": "66743dee6623f149d66f313b3a6572f99230106392fe4158c88561f3c1f2523f", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/task.toml": "fcddd98a824af0a0836e787ace2d60105be09100f1e022ea46a9620df3b691b0", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/tests/expected.json": "6bf078b77b27525dcbb86a3ec83aa1b132b48629369a333949c0187e0b6944f7", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/tests/scenario/NOTICE": "619007f94808622917a279011bae4ab1a2b52975282f36fae9e471fb43e55508", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/tests/scenario/episode.yaml": "1290cfa46263400fdedb50561e432db0d9fc3ecebbdee2bc03ed7825bd2821f2", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/tests/scenario/notes.md": "5b7fd07b758678db267cc9368659e33b412bbae1998829a890c86fe0ad370812", @@ -9924,20 +9928,20 @@ "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/docker-compose.yaml": "dbd0f8a1ce570b6818ffd98cf5cde4b6e4ec96d14f26ade7b26d5f88fda555d7", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/team/scenario/NOTICE": "619007f94808622917a279011bae4ab1a2b52975282f36fae9e471fb43e55508", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/team/scenario/episode.yaml": "08ceaefb9939e759ca96000a52ec38bd095cf6ada74cbe97a420311ebc624e16", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/team/scenario/notes.md": "dae337111b36909746068871f8590ad277cf57f00536edcaab04aa9df4420c86", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/team/scenario/record.json": "d22d12d475cc40f429c25a85eea8e1c6489f5aebdfe8f847cad842b1cbf8e2d3", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/team/scenario/source.md": "bf7adb79608a32e194b1d507829dbd999b1021853f0144325afe28e8e31ab203", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/team/task.json": "1edf84060c949a5336df98f6327a1234ff339256d9bd754c0d6db79b63e496d4", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/team/task.json": "f03726f005f06a7017fc4430fb60bd967453ffb17f4688d880c6479e2c2cea04", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -9950,13 +9954,13 @@ "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/task.toml": "29c1331dab23ddd173354b8d117736564f5e59d7f08b395f75884722ed044214", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/task.toml": "d6b5ce6eebd72c5c94433a44423107e6927a635cc60b31e44e5c840cb33dadeb", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/tests/expected.json": "d34f02baf78a2e213ec8adbac63bcdb412d353b5d5409f8f044c354d043f6142", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/tests/scenario/NOTICE": "619007f94808622917a279011bae4ab1a2b52975282f36fae9e471fb43e55508", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/tests/scenario/episode.yaml": "08ceaefb9939e759ca96000a52ec38bd095cf6ada74cbe97a420311ebc624e16", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/tests/scenario/notes.md": "dae337111b36909746068871f8590ad277cf57f00536edcaab04aa9df4420c86", @@ -9976,20 +9980,20 @@ "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/docker-compose.yaml": "b92d362f63f50c00aa5226000861259651fda5de8edd3765f3735b40db6f21a6", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/team/scenario/NOTICE": "619007f94808622917a279011bae4ab1a2b52975282f36fae9e471fb43e55508", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/team/scenario/episode.yaml": "08ceaefb9939e759ca96000a52ec38bd095cf6ada74cbe97a420311ebc624e16", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/team/scenario/notes.md": "dae337111b36909746068871f8590ad277cf57f00536edcaab04aa9df4420c86", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/team/scenario/record.json": "d22d12d475cc40f429c25a85eea8e1c6489f5aebdfe8f847cad842b1cbf8e2d3", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/team/scenario/source.md": "bf7adb79608a32e194b1d507829dbd999b1021853f0144325afe28e8e31ab203", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/team/task.json": "c98880345ff94a0aed3439e7968f8a212c9b2adf7e45ca8e459d1cb538e50edd", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/team/task.json": "3c6041c218af325a6e72df2d3b18d6a71a2cbcf8de2cea9a2861f2f03d09d548", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10002,13 +10006,13 @@ "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/task.toml": "c44fba8c1bae31d203a0d357665bcc5c9d120db25518e3a4740f9694c668cc92", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/task.toml": "330c6e0ee62cb21f8b75575c8a8a18a41702ea4b8fac4b95d847ebc7ee229203", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/tests/expected.json": "0d808762e978cf326dc3ffeb7a43b9e56f617e8f0b15cc8e0d25162f5b8b9050", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/tests/scenario/NOTICE": "619007f94808622917a279011bae4ab1a2b52975282f36fae9e471fb43e55508", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/tests/scenario/episode.yaml": "08ceaefb9939e759ca96000a52ec38bd095cf6ada74cbe97a420311ebc624e16", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/tests/scenario/notes.md": "dae337111b36909746068871f8590ad277cf57f00536edcaab04aa9df4420c86", @@ -10028,20 +10032,20 @@ "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/docker-compose.yaml": "4956afc029b2febc510719ea24123f513a93bb0d6fdcea9d47d906eb2f232311", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/team/scenario/NOTICE": "619007f94808622917a279011bae4ab1a2b52975282f36fae9e471fb43e55508", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/team/scenario/episode.yaml": "08ceaefb9939e759ca96000a52ec38bd095cf6ada74cbe97a420311ebc624e16", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/team/scenario/notes.md": "dae337111b36909746068871f8590ad277cf57f00536edcaab04aa9df4420c86", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/team/scenario/record.json": "d22d12d475cc40f429c25a85eea8e1c6489f5aebdfe8f847cad842b1cbf8e2d3", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/team/scenario/source.md": "bf7adb79608a32e194b1d507829dbd999b1021853f0144325afe28e8e31ab203", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/team/task.json": "3f1b26f6ea8f300bf697bb7caef79dc91c7b3933ba8cbb55623bfcb30aa8b89e", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/team/task.json": "92cd70599641bbdf2ea88e26d85e8f08a4da70e56be21b586f69a564a738b83c", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10054,13 +10058,13 @@ "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/task.toml": "669fc6e8849865d713f47a9f9ad79493aa938b7a8dcfda258e7d8bc44ee6d473", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/task.toml": "35636561b8b82e3011a24303ec9eb889e58e0cb973897b7372817a5216b1393d", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/tests/expected.json": "1e640736d917b4c1e68289c3a51a9b984b8ada2ed327424a125ed2ce5113ba02", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/tests/scenario/NOTICE": "619007f94808622917a279011bae4ab1a2b52975282f36fae9e471fb43e55508", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/tests/scenario/episode.yaml": "08ceaefb9939e759ca96000a52ec38bd095cf6ada74cbe97a420311ebc624e16", "tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/tests/scenario/notes.md": "dae337111b36909746068871f8590ad277cf57f00536edcaab04aa9df4420c86", @@ -10080,19 +10084,19 @@ "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/docker-compose.yaml": "7ec082fd56ce29cfb8e3598348ccb8ae828092f79b0a64cf0a3b206f888c8860", - "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/team/scenario/episode.yaml": "2b8a4aad474e1365f94946fcc4133dc2151b539424db71c673fff68bf4afb963", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/team/scenario/notes.md": "dd3df2376a6e171920291276243a3aeb01b3ca56cdd75eb7293af8644a2239d5", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/team/scenario/record.json": "24b7d2cddb95d0e23fb26526bfef4c7d58e9cc93afbbcb0a9e2e2ff9c1e6d16a", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/team/scenario/source.md": "41270190f1e5c4b83d854da2d4f23dcab4107f70d1a81e7c76f20a6f37190021", - "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/team/task.json": "29f7a04cbf8a233e30b3d1f25dde931d8bb37edf68abd24830d4ad5d542cdc74", + "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/team/task.json": "e205040967ab64308075c4cf9cc7b965c3e3a33d421de9631cb3f6e5ffb0605f", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10105,13 +10109,13 @@ "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/task.toml": "7e958795e94cd7232f6028f390ffe6c4da421699ad36b735a9e20050af44ba27", + "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/task.toml": "851593625fb0a6f42ef49d4bfd8b926d8297960c4390343a86ac6f6c2cae3f47", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/tests/expected.json": "8637a1c466712b540ad1d558b13a392698e6d05e3b04b7ed5db1f2352418976d", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/tests/scenario/episode.yaml": "2b8a4aad474e1365f94946fcc4133dc2151b539424db71c673fff68bf4afb963", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/tests/scenario/notes.md": "dd3df2376a6e171920291276243a3aeb01b3ca56cdd75eb7293af8644a2239d5", "tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/tests/scenario/record.json": "24b7d2cddb95d0e23fb26526bfef4c7d58e9cc93afbbcb0a9e2e2ff9c1e6d16a", @@ -10130,19 +10134,19 @@ "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/docker-compose.yaml": "34ef267e033a21f7570764255cf89c0cd1120d768a07e0d5cd99b157cd58c22b", - "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/team/scenario/episode.yaml": "8f965cf88704bdb083e729449457949f14a33044dc933336883ecd015f209e6d", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/team/scenario/notes.md": "ae8247e185799d6c553bed9efe9507c9dd4d29d79cb89a2b427aa4ef4b28115d", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/team/scenario/record.json": "473e5b696c03f550125d4600d1f7d9d4da8a99cc52cef5ae245c8e860149440e", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/team/scenario/source.md": "41270190f1e5c4b83d854da2d4f23dcab4107f70d1a81e7c76f20a6f37190021", - "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/team/task.json": "b5075abaf425b446b5d765e7fdf4457f172d8beca1a318e9404edfbdf120f104", + "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/team/task.json": "e3a53338f12cf8da2c8018925f2d7f08df1fc6808272d0adae5aeb327774054f", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10155,13 +10159,13 @@ "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/task.toml": "235876d6223ceff22c34a323fdf4e75812444922f404877485c23ed7b8ce4452", + "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/task.toml": "7b7ce89068ccf5c8198d9bdd12f9d5710bacc4e850f4e90a8da8d85aa23deb48", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/tests/expected.json": "6a8a70df0e141f412b12b4e5df67bd86c08c1eebc52ec49fec3aad3b9a5488aa", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/tests/scenario/episode.yaml": "8f965cf88704bdb083e729449457949f14a33044dc933336883ecd015f209e6d", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/tests/scenario/notes.md": "ae8247e185799d6c553bed9efe9507c9dd4d29d79cb89a2b427aa4ef4b28115d", "tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/tests/scenario/record.json": "473e5b696c03f550125d4600d1f7d9d4da8a99cc52cef5ae245c8e860149440e", @@ -10180,19 +10184,19 @@ "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/docker-compose.yaml": "fc4bbe8561163b971dfc872e52741db14f0b4d6538edf1024bac76718812fdd8", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/team/scenario/episode.yaml": "2b8a4aad474e1365f94946fcc4133dc2151b539424db71c673fff68bf4afb963", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/team/scenario/notes.md": "dd3df2376a6e171920291276243a3aeb01b3ca56cdd75eb7293af8644a2239d5", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/team/scenario/record.json": "24b7d2cddb95d0e23fb26526bfef4c7d58e9cc93afbbcb0a9e2e2ff9c1e6d16a", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/team/scenario/source.md": "41270190f1e5c4b83d854da2d4f23dcab4107f70d1a81e7c76f20a6f37190021", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/team/task.json": "a113535f05fb888c356dff59ce06ac2e71673e8336b08f6162765b7b6c5dcce1", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/team/task.json": "ada78fbab9c72aa86d5eec99e507944b9fb724e2a37874da8983a1ec09ca4368", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10205,13 +10209,13 @@ "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/task.toml": "51b30e59ff056b322322b835456b9114864ab8750f7310c212bc14092c987ce2", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/task.toml": "0363f4101c84a5243f74c62160168a5c6290055c02511899958b955eefb46de5", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/tests/expected.json": "2cb40c9156fcb382c7ff30466ced75705bb3103132d4d34025b688a3edcffa59", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/tests/scenario/episode.yaml": "2b8a4aad474e1365f94946fcc4133dc2151b539424db71c673fff68bf4afb963", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/tests/scenario/notes.md": "dd3df2376a6e171920291276243a3aeb01b3ca56cdd75eb7293af8644a2239d5", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/tests/scenario/record.json": "24b7d2cddb95d0e23fb26526bfef4c7d58e9cc93afbbcb0a9e2e2ff9c1e6d16a", @@ -10230,19 +10234,19 @@ "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/docker-compose.yaml": "ead0af9e1b5df75141b133f1dedf4d28df7c1e23bac9e4450a2f76ae62e2ff3a", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/team/scenario/episode.yaml": "2b8a4aad474e1365f94946fcc4133dc2151b539424db71c673fff68bf4afb963", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/team/scenario/notes.md": "dd3df2376a6e171920291276243a3aeb01b3ca56cdd75eb7293af8644a2239d5", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/team/scenario/record.json": "24b7d2cddb95d0e23fb26526bfef4c7d58e9cc93afbbcb0a9e2e2ff9c1e6d16a", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/team/scenario/source.md": "41270190f1e5c4b83d854da2d4f23dcab4107f70d1a81e7c76f20a6f37190021", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/team/task.json": "f213a8000d592ab40a32c2e80ba0def546eeca83a74e8e27f7e687cf06f84ef3", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/team/task.json": "45c330c290e470959e0453a7c26495fd716bdf4972e57772d6604e7e51f0f3bc", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10255,13 +10259,13 @@ "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/task.toml": "c25887920b72d22e5cb40cc1685848b5fd37d639a1714cef1b274300fe705bd4", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/task.toml": "db5788c2069f1ce04291ac1aa0523e8df25567d7bc31342c235b90bb66623bc0", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/tests/expected.json": "2427727b5afdcf15d68f4a269edcf8bfcd588a9f7c84f0fed83661de210a112f", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/tests/scenario/episode.yaml": "2b8a4aad474e1365f94946fcc4133dc2151b539424db71c673fff68bf4afb963", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/tests/scenario/notes.md": "dd3df2376a6e171920291276243a3aeb01b3ca56cdd75eb7293af8644a2239d5", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/tests/scenario/record.json": "24b7d2cddb95d0e23fb26526bfef4c7d58e9cc93afbbcb0a9e2e2ff9c1e6d16a", @@ -10280,19 +10284,19 @@ "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/docker-compose.yaml": "6b35127368185660454ec609afca6bdaca3cec3758e82ed1e10f9553d09871c5", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/team/scenario/episode.yaml": "2b8a4aad474e1365f94946fcc4133dc2151b539424db71c673fff68bf4afb963", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/team/scenario/notes.md": "dd3df2376a6e171920291276243a3aeb01b3ca56cdd75eb7293af8644a2239d5", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/team/scenario/record.json": "24b7d2cddb95d0e23fb26526bfef4c7d58e9cc93afbbcb0a9e2e2ff9c1e6d16a", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/team/scenario/source.md": "41270190f1e5c4b83d854da2d4f23dcab4107f70d1a81e7c76f20a6f37190021", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/team/task.json": "cfb53c65aaed35ca885ebe283be748c315c9cb5aecae7e47c194315ae376f5ff", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/team/task.json": "4cf5b45111150248a4d7ee637527eefa17ba65645e44a3edda675d4bd06a752f", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10305,13 +10309,13 @@ "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/task.toml": "2fcf9d19e7e3b713c456823994063180b52c7c16c8473094afc5145b9abad6df", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/task.toml": "f7f8f910153da570d527021e4da7565d116b3ba9c68dfec15f9a2262209fa2db", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/tests/expected.json": "564a940deeba7b9b4527ff2bce565fdc07747e8aefae36107255fca43d901999", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/tests/scenario/episode.yaml": "2b8a4aad474e1365f94946fcc4133dc2151b539424db71c673fff68bf4afb963", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/tests/scenario/notes.md": "dd3df2376a6e171920291276243a3aeb01b3ca56cdd75eb7293af8644a2239d5", "tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/tests/scenario/record.json": "24b7d2cddb95d0e23fb26526bfef4c7d58e9cc93afbbcb0a9e2e2ff9c1e6d16a", @@ -10330,19 +10334,19 @@ "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/docker-compose.yaml": "700c1c8bc33c3928f43d1894b3d7f00db7558baa0ac3fbfc75af707afaf2af5b", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/team/scenario/episode.yaml": "c8c5b4425a94d7907da9058dfbe2dd1d0def106b3290f6e91b49b06240b6dcd8", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/team/scenario/notes.md": "4b79ef5060463af1f1785bee1ed9c755f5fae8421fdb7a170a8ea3408bd8696b", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/team/scenario/record.json": "a3d92d5ee6747b3e5a4b4868c30404e74569bc7aa199d9bd5bba36a855e1d76a", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/team/scenario/source.md": "f654fd537c62a530b09bc883f1be0279ea717bea900a7f3f41abf51e738a9698", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/team/task.json": "0a4645e94511187d90716dab96223fbe1619c4922fd0c85e594d2460ddd13216", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/team/task.json": "bf5756da9ea3c4aa94dfdfb728a1b64e89adabfb30939daf532379df71e48e73", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10355,13 +10359,13 @@ "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/task.toml": "2f77a8d38f55536f6d5c889b1e589c0207d713aec759e330963f3fe3baf9e079", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/task.toml": "8b5d88d59e37b3cb8bc1ded68413b46e6e020209e6c8f446d286238b2d2e7e65", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/tests/expected.json": "f2a8e9277e2b365e5e69b9d02ee36c409becfd00075639527533d167dee64a17", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/tests/scenario/episode.yaml": "c8c5b4425a94d7907da9058dfbe2dd1d0def106b3290f6e91b49b06240b6dcd8", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/tests/scenario/notes.md": "4b79ef5060463af1f1785bee1ed9c755f5fae8421fdb7a170a8ea3408bd8696b", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/tests/scenario/record.json": "a3d92d5ee6747b3e5a4b4868c30404e74569bc7aa199d9bd5bba36a855e1d76a", @@ -10380,19 +10384,19 @@ "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/docker-compose.yaml": "eeb0477a7bf819c9f1ce6bbf2deb703fa17f2c54a19ee26a3ba88a3c1ad702e4", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/team/scenario/episode.yaml": "86c286243fa43ee5f577cba9ca8456a751045ad7ae374bffca4f9d4ca500a11b", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/team/scenario/notes.md": "c365ec06c6e4fc3ffc9f7f7e0921d36e372412310b45cb3b12e5357f09d4a192", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/team/scenario/record.json": "5004d88bb1ceeca9f79c17737af52029786ceb088e1ff028e32e9cff6f96ebcb", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/team/scenario/source.md": "f654fd537c62a530b09bc883f1be0279ea717bea900a7f3f41abf51e738a9698", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/team/task.json": "f0815d0ca5907bc94650a72fa0542c00e7c30489479faf7bbea6ff6c7d3282d2", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/team/task.json": "2591b402f5ab3751493265fbce249c96e06592e3c154aaea3801d46829ed6260", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10405,13 +10409,13 @@ "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/task.toml": "64298027803c1990f471a9c26b7d52a726dd43346965d07be0ffae77c6d8522e", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/task.toml": "1063299f44583b37b04c3da97b8db4a90f6b589c6c5bb3e6df2fb9bac4ecdf78", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/tests/expected.json": "939c863508f9bf4eb0acd3ae42225ec984f57e631938e25c31ca6e7bfdd6ff13", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/tests/scenario/episode.yaml": "86c286243fa43ee5f577cba9ca8456a751045ad7ae374bffca4f9d4ca500a11b", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/tests/scenario/notes.md": "c365ec06c6e4fc3ffc9f7f7e0921d36e372412310b45cb3b12e5357f09d4a192", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/tests/scenario/record.json": "5004d88bb1ceeca9f79c17737af52029786ceb088e1ff028e32e9cff6f96ebcb", @@ -10430,19 +10434,19 @@ "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/docker-compose.yaml": "6aba24216e102b4be8e18598ea83f32333ed8b636599f037de0ab3c24d366cc3", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/team/scenario/episode.yaml": "c8c5b4425a94d7907da9058dfbe2dd1d0def106b3290f6e91b49b06240b6dcd8", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/team/scenario/notes.md": "4b79ef5060463af1f1785bee1ed9c755f5fae8421fdb7a170a8ea3408bd8696b", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/team/scenario/record.json": "a3d92d5ee6747b3e5a4b4868c30404e74569bc7aa199d9bd5bba36a855e1d76a", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/team/scenario/source.md": "f654fd537c62a530b09bc883f1be0279ea717bea900a7f3f41abf51e738a9698", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/team/task.json": "98d4e3c7ab14c65e376b9da2989299ad9817bd51b92ebc92f1b372ee7fc52d54", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/team/task.json": "752c902fa6c6bd6468162a24728f5143dfd5ae9085fd8cdd595d2694eb8db5a6", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10455,13 +10459,13 @@ "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/task.toml": "cdd9c0ec76ec5d9a2c88f15308d8c70ea0e57320113d5caac954290876e55762", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/task.toml": "532962faf724e4eef5e009a4715d769028a8498b5a74d44d5be327b4b4ef43f7", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/tests/expected.json": "60d036b6323d62709accf1b299e2704b73611b86a6f31ab9cf4bdf4e11540243", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/tests/scenario/episode.yaml": "c8c5b4425a94d7907da9058dfbe2dd1d0def106b3290f6e91b49b06240b6dcd8", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/tests/scenario/notes.md": "4b79ef5060463af1f1785bee1ed9c755f5fae8421fdb7a170a8ea3408bd8696b", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/tests/scenario/record.json": "a3d92d5ee6747b3e5a4b4868c30404e74569bc7aa199d9bd5bba36a855e1d76a", @@ -10480,19 +10484,19 @@ "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/docker-compose.yaml": "78c6e3a13447199b1460e4aefdf71e8b158b14e291b07298d489050cdcecfe8e", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/team/scenario/episode.yaml": "c8c5b4425a94d7907da9058dfbe2dd1d0def106b3290f6e91b49b06240b6dcd8", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/team/scenario/notes.md": "4b79ef5060463af1f1785bee1ed9c755f5fae8421fdb7a170a8ea3408bd8696b", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/team/scenario/record.json": "a3d92d5ee6747b3e5a4b4868c30404e74569bc7aa199d9bd5bba36a855e1d76a", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/team/scenario/source.md": "f654fd537c62a530b09bc883f1be0279ea717bea900a7f3f41abf51e738a9698", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/team/task.json": "f1d35ceb17a25ffbf8854cecd95b781e99cf2d58ea1a70f666389e0b45ce0980", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/team/task.json": "c21a03d647742c66fdf5b72bb71c15bb9843c92b5cf253092561ac9126443215", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10505,13 +10509,13 @@ "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/task.toml": "a9ab27778afcba694c616652ba753646787828dc78d0830e6cffeaa8c8cf498d", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/task.toml": "9cae37ce75c273a49831e957ccac755bff48fc72861b4a53359a8698d7a23f07", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/tests/expected.json": "81f3e91edb4bb019216c61125f273d65c4f4fd1fb5f3e3cc042c58e8763aa6de", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/tests/scenario/episode.yaml": "c8c5b4425a94d7907da9058dfbe2dd1d0def106b3290f6e91b49b06240b6dcd8", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/tests/scenario/notes.md": "4b79ef5060463af1f1785bee1ed9c755f5fae8421fdb7a170a8ea3408bd8696b", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/tests/scenario/record.json": "a3d92d5ee6747b3e5a4b4868c30404e74569bc7aa199d9bd5bba36a855e1d76a", @@ -10530,19 +10534,19 @@ "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/docker-compose.yaml": "e2812f050fecad9b0130864e3c3c6f627a58d79dc11d7bf8a1938718e6940780", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/team/scenario/episode.yaml": "c8c5b4425a94d7907da9058dfbe2dd1d0def106b3290f6e91b49b06240b6dcd8", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/team/scenario/notes.md": "4b79ef5060463af1f1785bee1ed9c755f5fae8421fdb7a170a8ea3408bd8696b", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/team/scenario/record.json": "a3d92d5ee6747b3e5a4b4868c30404e74569bc7aa199d9bd5bba36a855e1d76a", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/team/scenario/source.md": "f654fd537c62a530b09bc883f1be0279ea717bea900a7f3f41abf51e738a9698", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/team/task.json": "dd868e098dcc903b9cfd12cb6e23304b0a67484718b46fead2194ce6a4c57e9d", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/team/task.json": "9f9a9dae69c2bd9633d981bf5395c7f56d59baa33f29117635f4c785655e98af", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10555,13 +10559,13 @@ "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/task.toml": "0818581e7e88f538ab7add6209f8a251f48fdae0dccfb6498c328955c9187d9c", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/task.toml": "2b114c0486438ceda47d33f1f345919aa21b26fb1d6c1be3e9d7ed31d4938831", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/tests/expected.json": "f4cdba534d9409373ae6e1a75d0138e46f1dae2424e9ca1d960e0e9155979ea8", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/tests/scenario/episode.yaml": "c8c5b4425a94d7907da9058dfbe2dd1d0def106b3290f6e91b49b06240b6dcd8", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/tests/scenario/notes.md": "4b79ef5060463af1f1785bee1ed9c755f5fae8421fdb7a170a8ea3408bd8696b", "tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/tests/scenario/record.json": "a3d92d5ee6747b3e5a4b4868c30404e74569bc7aa199d9bd5bba36a855e1d76a", @@ -10580,19 +10584,19 @@ "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/docker-compose.yaml": "14420772b5edd91f09543a06fd78118d49fa8560752482b5f5d023b60ee7f5e1", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/team/scenario/episode.yaml": "d38403c37b6dda8991bd7b7804c8e50b70d5395d5ba5f1a86543a68f8b9f6e77", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/team/scenario/notes.md": "97bec64619ca7fbd6dd8567c5e17e1149810f59b2bf84587e188130b592b1402", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/team/scenario/record.json": "aa6098dcd68e9f8a2199724ef9385d1eb3d07a08d36a823303d0558c80184b85", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/team/scenario/source.md": "69e024c8b46128b179f48016e0fc0e1d7def062ef1bca08027f9e05f20c56b32", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/team/task.json": "7d0178d2e68e22874c632c4e862cc6603403dcecd2f4b8dcc89ec1142d1b9bb4", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/team/task.json": "3c70b3696bc122b7be9cab0b1ca21a540e1358f9a180884e6b14b1ffccfe0b16", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10605,13 +10609,13 @@ "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/task.toml": "d56b57480e302ce3d3c3b7380668b5956275279659df2016dd250647e495a3f7", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/task.toml": "296427f1ec029a6f0c2e313ccd10f7707489dfce5799846cee89917e8865f613", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/tests/expected.json": "1d00c03df55697425fc1ae259b18c910d59b14918f997c359d49384c12e253fa", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/tests/scenario/episode.yaml": "d38403c37b6dda8991bd7b7804c8e50b70d5395d5ba5f1a86543a68f8b9f6e77", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/tests/scenario/notes.md": "97bec64619ca7fbd6dd8567c5e17e1149810f59b2bf84587e188130b592b1402", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/tests/scenario/record.json": "aa6098dcd68e9f8a2199724ef9385d1eb3d07a08d36a823303d0558c80184b85", @@ -10630,19 +10634,19 @@ "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/docker-compose.yaml": "8613d5552ef5da84d762e7dd6ff6d442c0dcdf030a3e6ddd8f91239378f2a51e", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/team/scenario/episode.yaml": "e9d033a9d078784d7b5b4698fea9649ecea29ea27c3b805c6b287ae6ad890251", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/team/scenario/notes.md": "08272d2ae6436357483ce3137df769c41ee89dba784cc43cd0c7e839b5aed5a2", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/team/scenario/record.json": "215c727719343e07c14b033ce3bd72c3a226cbaa4fca9a3a9a5da21349505000", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/team/scenario/source.md": "69e024c8b46128b179f48016e0fc0e1d7def062ef1bca08027f9e05f20c56b32", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/team/task.json": "e1efb3acdb4f26ea65a032695816482949053a3a20986970904a123dab3c41dc", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/team/task.json": "d2d7187386297733e48e8ebe43660fbdcd5a3e7d7eb89c53208634a813fcc9de", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10655,13 +10659,13 @@ "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/task.toml": "4ca5a0e6fdf7c17de68d80eea3e9154e664d4b15ae5d32c86d988c8a1ad62b73", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/task.toml": "5b8704fb26bfe214632d535fa0c16549a3bf055155428eef6c409565f85ce5f0", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/tests/expected.json": "7babc4b4550dfbe0a0b5fa22f077218aa371e8374860c4b3c06ee9ca6a451aee", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/tests/scenario/episode.yaml": "e9d033a9d078784d7b5b4698fea9649ecea29ea27c3b805c6b287ae6ad890251", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/tests/scenario/notes.md": "08272d2ae6436357483ce3137df769c41ee89dba784cc43cd0c7e839b5aed5a2", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/tests/scenario/record.json": "215c727719343e07c14b033ce3bd72c3a226cbaa4fca9a3a9a5da21349505000", @@ -10680,19 +10684,19 @@ "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/docker-compose.yaml": "4c3ce0a0ea5152d2b27b364f3ac8a7337bed285d88c41a789195c68c0ccbdb77", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/team/scenario/episode.yaml": "d38403c37b6dda8991bd7b7804c8e50b70d5395d5ba5f1a86543a68f8b9f6e77", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/team/scenario/notes.md": "97bec64619ca7fbd6dd8567c5e17e1149810f59b2bf84587e188130b592b1402", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/team/scenario/record.json": "aa6098dcd68e9f8a2199724ef9385d1eb3d07a08d36a823303d0558c80184b85", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/team/scenario/source.md": "69e024c8b46128b179f48016e0fc0e1d7def062ef1bca08027f9e05f20c56b32", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/team/task.json": "579c804d13784c841cf6abed7e861cf776bec3bcacf4cdea16e10625eb9af717", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/team/task.json": "8f105d2f79083ff3810ebfbb0957f8f7a586a70527993f6efa7d8459c756b847", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10705,13 +10709,13 @@ "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/task.toml": "b3ed0a34e972b4b878c7e179b7c05b02e561ae969085fcf852eca7316a05d217", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/task.toml": "b794cfee74aee29449e1e4ff96b17f3e257fb5b1cdc1c1e589e348989f243995", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/tests/expected.json": "401508d732b4efe4b0b4c01d91f49f2f488741e69071234db66afbc4a02a4c7d", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/tests/scenario/episode.yaml": "d38403c37b6dda8991bd7b7804c8e50b70d5395d5ba5f1a86543a68f8b9f6e77", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/tests/scenario/notes.md": "97bec64619ca7fbd6dd8567c5e17e1149810f59b2bf84587e188130b592b1402", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/tests/scenario/record.json": "aa6098dcd68e9f8a2199724ef9385d1eb3d07a08d36a823303d0558c80184b85", @@ -10730,19 +10734,19 @@ "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/docker-compose.yaml": "5a9632d039652210fd562c8827a2f7a5b866424b8c44216975921afd5861994a", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/team/scenario/episode.yaml": "d38403c37b6dda8991bd7b7804c8e50b70d5395d5ba5f1a86543a68f8b9f6e77", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/team/scenario/notes.md": "97bec64619ca7fbd6dd8567c5e17e1149810f59b2bf84587e188130b592b1402", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/team/scenario/record.json": "aa6098dcd68e9f8a2199724ef9385d1eb3d07a08d36a823303d0558c80184b85", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/team/scenario/source.md": "69e024c8b46128b179f48016e0fc0e1d7def062ef1bca08027f9e05f20c56b32", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/team/task.json": "9a3aabce765836ac0487c6d6b90feb97ab7adde5d5ebd9eb5977dd4754f6cefb", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/team/task.json": "de96281d7796162126817a737e90d3e0b2b6087453b65e9542145257b831af8d", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10755,13 +10759,13 @@ "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/task.toml": "3b309c039abe0120d55c44a886e0f1d6763784d0fd62a726e1cf7a25694bea7e", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/task.toml": "17914f8b5c84eb8f2c23ec8f14648b2d5ed1d9365af6de9eb56dfbe2a757fa3f", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/tests/expected.json": "84e260d83a26b6a77cf279957f4453ac0fcbb958168a2be58a4c279030b01754", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/tests/scenario/episode.yaml": "d38403c37b6dda8991bd7b7804c8e50b70d5395d5ba5f1a86543a68f8b9f6e77", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/tests/scenario/notes.md": "97bec64619ca7fbd6dd8567c5e17e1149810f59b2bf84587e188130b592b1402", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/tests/scenario/record.json": "aa6098dcd68e9f8a2199724ef9385d1eb3d07a08d36a823303d0558c80184b85", @@ -10780,19 +10784,19 @@ "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/docker-compose.yaml": "444c46d858c59c60465049cd69f303d81286b5d6bcb0df9d770d0812975fe591", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/team/scenario/episode.yaml": "d38403c37b6dda8991bd7b7804c8e50b70d5395d5ba5f1a86543a68f8b9f6e77", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/team/scenario/notes.md": "97bec64619ca7fbd6dd8567c5e17e1149810f59b2bf84587e188130b592b1402", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/team/scenario/record.json": "aa6098dcd68e9f8a2199724ef9385d1eb3d07a08d36a823303d0558c80184b85", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/team/scenario/source.md": "69e024c8b46128b179f48016e0fc0e1d7def062ef1bca08027f9e05f20c56b32", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/team/task.json": "1041b12457030969a53a8dbf5570dd1b4973639b4a92ba20cad983d7cf708ca2", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/team/task.json": "66d3aa5f28007e6ff71a54f53c9f14edd86f08e2296e6c21c9a417a94a662e48", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10805,13 +10809,13 @@ "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/task.toml": "aaeee47e802d9125ca9843bb99250dbb4c3b811d1a7dd56ff050d73e693ed199", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/task.toml": "6f396bc835f47dc5b82bf321da6ac4133dd776adc3fb92545f57e86394f91bd6", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/tests/expected.json": "df591b9e7db4c6f6bcd822a091ce7ec376bafc002748e43776d891c13ad5e217", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/tests/scenario/episode.yaml": "d38403c37b6dda8991bd7b7804c8e50b70d5395d5ba5f1a86543a68f8b9f6e77", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/tests/scenario/notes.md": "97bec64619ca7fbd6dd8567c5e17e1149810f59b2bf84587e188130b592b1402", "tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/tests/scenario/record.json": "aa6098dcd68e9f8a2199724ef9385d1eb3d07a08d36a823303d0558c80184b85", @@ -10830,19 +10834,19 @@ "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/docker-compose.yaml": "4260d172e9dd871fe56e4b02be1624a2135639b80900a56ae97519d3d54fd3c0", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/team/scenario/episode.yaml": "86d98a2c030b03f2834d272a7d2ab8e79092db7d7791b7ee4338e62d067e689c", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/team/scenario/notes.md": "9fb05afa0b6100303b56d95f8bfea98a760624da36a8b99e52215ba85871c2b6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/team/scenario/record.json": "3c94f48ebc41ac06c5b90ff7f14f8c93fa7b19f12c07edae52a327bc530f504e", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/team/scenario/source.md": "d3d2d7c0f26a867bb8517ef7cf6f1f43921fa5e8be45dc651e2d26923d61401f", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/team/task.json": "d6072c25c88ca4c57b506f09a9a33c408b2c5f1674dfa8aca5ba3c04d4ffdb59", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/team/task.json": "28da14381aaf85170aab1bedb93f8c2101919f6dc17af5a77ddd5c0538c9325b", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10855,13 +10859,13 @@ "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/task.toml": "a4680641eccb44e9ee188313f1b3814987d63f98a7bd093128f5548d6ed5935a", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/task.toml": "c02d763522b87d0bcf5870be3df3a1b07b2526f83934966b9d43f3a0c8599786", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/tests/expected.json": "19368c1535b775919ca07934136b783174e2e9eacd3333285e140c7e6281ee9a", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/tests/scenario/episode.yaml": "86d98a2c030b03f2834d272a7d2ab8e79092db7d7791b7ee4338e62d067e689c", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/tests/scenario/notes.md": "9fb05afa0b6100303b56d95f8bfea98a760624da36a8b99e52215ba85871c2b6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/tests/scenario/record.json": "3c94f48ebc41ac06c5b90ff7f14f8c93fa7b19f12c07edae52a327bc530f504e", @@ -10880,19 +10884,19 @@ "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/docker-compose.yaml": "90220f70596d9485ad3672e05ff0e64c739feab945d2fcc030d2a581ac10767c", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/team/scenario/episode.yaml": "7691792ecfeb259bc37b45f994eb7a3eeee15b1bbcdfcbf034b43934f0828329", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/team/scenario/notes.md": "14cb8a5bc559a30a091772df05ed494e44cd300cae01b2b53feaebd0e67222f4", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/team/scenario/record.json": "4be5aeaa4613d9f69cd25fa5655c38597e9bc570341755f49f7b243f119eebee", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/team/scenario/source.md": "d3d2d7c0f26a867bb8517ef7cf6f1f43921fa5e8be45dc651e2d26923d61401f", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/team/task.json": "61f2a7560c3e95e37ef39e49c7eab29257853f1cc53800374b10b4dda13d5ad8", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/team/task.json": "a2fc35c7b22830c453629acb1ae6614e68394a5066600803bbb6a00c3ebaccb8", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10905,13 +10909,13 @@ "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/task.toml": "bbc5d3c0bccbd0f82548e032ae57deaeb7abe36b1e3b9372ef64862c0dde976d", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/task.toml": "3d425762a02424b08017fdf46c53adef284be682d786073d9b0309198c5b370a", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/tests/expected.json": "2f23b0c1b37fef67456e5185083d56e13308d81e6c66879cadf5531699903c68", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/tests/scenario/episode.yaml": "7691792ecfeb259bc37b45f994eb7a3eeee15b1bbcdfcbf034b43934f0828329", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/tests/scenario/notes.md": "14cb8a5bc559a30a091772df05ed494e44cd300cae01b2b53feaebd0e67222f4", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/tests/scenario/record.json": "4be5aeaa4613d9f69cd25fa5655c38597e9bc570341755f49f7b243f119eebee", @@ -10930,19 +10934,19 @@ "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/docker-compose.yaml": "fe272407197130a3702142d832b9db4c0bd409275d76c7817c5cd6f2e19c5fc0", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/team/scenario/episode.yaml": "86d98a2c030b03f2834d272a7d2ab8e79092db7d7791b7ee4338e62d067e689c", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/team/scenario/notes.md": "9fb05afa0b6100303b56d95f8bfea98a760624da36a8b99e52215ba85871c2b6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/team/scenario/record.json": "3c94f48ebc41ac06c5b90ff7f14f8c93fa7b19f12c07edae52a327bc530f504e", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/team/scenario/source.md": "d3d2d7c0f26a867bb8517ef7cf6f1f43921fa5e8be45dc651e2d26923d61401f", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/team/task.json": "2d9e638eec90d66c44fe035da15f5700546b9defc9f2e56f079affe5668ad500", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/team/task.json": "195c6814deda5c5154bfcc309096b2f341c18b77779f07148a238aa0bc77c8e9", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -10955,13 +10959,13 @@ "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/task.toml": "b8d0afd551373faa9dc5d98ca6ed8dd4e66f7284aed9212568fed365dea4c2cc", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/task.toml": "a90b0c90ec64eac903cf6109a8053ce7bb6160ea9fe6fd6211cd46c11e8b8b1c", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/tests/expected.json": "15ab97e5cd3337aebf8f1d2368c187db19f32bcb560f7e85aec18b84eeeee1da", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/tests/scenario/episode.yaml": "86d98a2c030b03f2834d272a7d2ab8e79092db7d7791b7ee4338e62d067e689c", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/tests/scenario/notes.md": "9fb05afa0b6100303b56d95f8bfea98a760624da36a8b99e52215ba85871c2b6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/tests/scenario/record.json": "3c94f48ebc41ac06c5b90ff7f14f8c93fa7b19f12c07edae52a327bc530f504e", @@ -10980,19 +10984,19 @@ "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/docker-compose.yaml": "b1138a20a47958b234c1dd0a30275d8c82799479d2f6dde3cc4edde97bd1b53a", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/team/scenario/episode.yaml": "86d98a2c030b03f2834d272a7d2ab8e79092db7d7791b7ee4338e62d067e689c", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/team/scenario/notes.md": "9fb05afa0b6100303b56d95f8bfea98a760624da36a8b99e52215ba85871c2b6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/team/scenario/record.json": "3c94f48ebc41ac06c5b90ff7f14f8c93fa7b19f12c07edae52a327bc530f504e", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/team/scenario/source.md": "d3d2d7c0f26a867bb8517ef7cf6f1f43921fa5e8be45dc651e2d26923d61401f", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/team/task.json": "08cb2f4ac83c398e19cf494182cb7e81a98c9bdf29af18fdc2a8e7f78bf2503a", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/team/task.json": "2a1674cf93a19f76e8f3f28ba9bf9423e0076c6c1e7dfccfde94c14f94b80ae3", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11005,13 +11009,13 @@ "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/task.toml": "f4c9c193da0ff2555ca456e52031823981c3570a4afa080f59cf1d0808d473a3", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/task.toml": "de670df949dc9362e82020b6a2c2031c9adc0a95251b4f6ef1c958eec0ef5a9e", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/tests/expected.json": "0c23bf2684c010fe7127dbe2f11e3ad85cca0924dab90834579d486df0b56d0e", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/tests/scenario/episode.yaml": "86d98a2c030b03f2834d272a7d2ab8e79092db7d7791b7ee4338e62d067e689c", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/tests/scenario/notes.md": "9fb05afa0b6100303b56d95f8bfea98a760624da36a8b99e52215ba85871c2b6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/tests/scenario/record.json": "3c94f48ebc41ac06c5b90ff7f14f8c93fa7b19f12c07edae52a327bc530f504e", @@ -11030,19 +11034,19 @@ "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/docker-compose.yaml": "149645deea3e853719748135dce2febb9c677e13e24d0eaa69e9cc289a5075b2", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/team/scenario/episode.yaml": "86d98a2c030b03f2834d272a7d2ab8e79092db7d7791b7ee4338e62d067e689c", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/team/scenario/notes.md": "9fb05afa0b6100303b56d95f8bfea98a760624da36a8b99e52215ba85871c2b6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/team/scenario/record.json": "3c94f48ebc41ac06c5b90ff7f14f8c93fa7b19f12c07edae52a327bc530f504e", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/team/scenario/source.md": "d3d2d7c0f26a867bb8517ef7cf6f1f43921fa5e8be45dc651e2d26923d61401f", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/team/task.json": "a4612e64da5642e41591a3764783adcdab1336c0d78e1babf98530780529a397", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/team/task.json": "7f2d2a7dfb7a00bdde3c47870307fe909b4bfa98dc4f5bb306996802e18179d8", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11055,13 +11059,13 @@ "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/task.toml": "34a680345e65d9335f4d68a8a799053f7dbdc901c0328ca10feec0c5cd4bcbe2", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/task.toml": "c48c6f678760145c62c939d6abb5937d28f66daa9763104a9cabec9caf485cd3", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/tests/expected.json": "03b8762ca6e265e90a36a046e3522e271b9e43976675939caf86a8aee25600a0", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/tests/scenario/episode.yaml": "86d98a2c030b03f2834d272a7d2ab8e79092db7d7791b7ee4338e62d067e689c", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/tests/scenario/notes.md": "9fb05afa0b6100303b56d95f8bfea98a760624da36a8b99e52215ba85871c2b6", "tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/tests/scenario/record.json": "3c94f48ebc41ac06c5b90ff7f14f8c93fa7b19f12c07edae52a327bc530f504e", @@ -11080,19 +11084,19 @@ "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/docker-compose.yaml": "f7c5688962f6f9da48685da346f10a3a7dbd8cac0b925fb08ede1b62fe15f7da", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/team/scenario/episode.yaml": "78044f0231e8df58363b88dc9b82a6a51c71c2fd7b24338c68b0060292e01add", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/team/scenario/notes.md": "ef7e4e390d37717227e00d64384a5bc6626bb85650bc03f3577ca27c03e05425", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/team/scenario/record.json": "3af94f0aef942022f05ea08afa4b2d63bb903b7bd6f93e10bda13adda74199b9", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/team/scenario/source.md": "80b2e56bc08e7b83a91a32285f5b6233a80e1dbcc4f4bcd530bdc354129f5a21", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/team/task.json": "f284360a507aa0da3f35a21de6d877381e6ac2e0001013ede1126f22a8cce2f6", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/team/task.json": "04500ed18e6f5fdf3d4e4cc7b84069f605ca70afba4cdbf487899c8fe03c5e28", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11105,13 +11109,13 @@ "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/task.toml": "9a31b96f3c2eddb3f79f11580c5e196a65ef35dfe1da48b34646f20a0e0cedd8", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/task.toml": "56b981e487ec5fd3ff0b4b6f1446ba03217d3e3c381e778419bbb45ca6952aa7", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/tests/expected.json": "09a76302a3bdf77f01a018c318dfa8be042f6ddff46f3ce0df5707c92904d959", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/tests/scenario/episode.yaml": "78044f0231e8df58363b88dc9b82a6a51c71c2fd7b24338c68b0060292e01add", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/tests/scenario/notes.md": "ef7e4e390d37717227e00d64384a5bc6626bb85650bc03f3577ca27c03e05425", "tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/tests/scenario/record.json": "3af94f0aef942022f05ea08afa4b2d63bb903b7bd6f93e10bda13adda74199b9", @@ -11130,19 +11134,19 @@ "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/docker-compose.yaml": "4fe636a4235db097b5287c153d53286f94cd2b5595ff7ba8d1f0c829ed0eee83", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/team/scenario/episode.yaml": "a68cc650fd43a0a1da8e0ebfe7771f239f3d9aa591b6bee4cc95d39edd754a0e", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/team/scenario/notes.md": "51490ded1b98b1846ca45c6b85a7a4a37115418f2224b364d86fefac3250ab72", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/team/scenario/record.json": "6f654d1cfae20cc8b64f46ffe3acb8d8a8273fec818c8aa786f9adec3d71d7f6", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/team/scenario/source.md": "dfcb87e889054c045544326e357f71c1a9514c6350c667e316646c7e501ea926", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/team/task.json": "d6079e660e8b299015e11d54e557f8f87be4067356f8ae96121965ba28a725cb", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/team/task.json": "e88f42bec73df9deabcf3808f81c038fcfc2ea922bc22fd8ed3abe6f83459fe0", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11155,13 +11159,13 @@ "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/task.toml": "0238bbd8b111200ed1f6ca823171321757889404f9b0981250ffb9f6f3181390", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/task.toml": "81ce28b08babef02a4610527e4fdefbd2c02c37933ca5a8cac3b3ea914dfd753", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/tests/expected.json": "b3b8d74b0127d7f46d9082250156a9bccc8167f5da7c5964d07ff46b3f8d512d", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/tests/scenario/episode.yaml": "a68cc650fd43a0a1da8e0ebfe7771f239f3d9aa591b6bee4cc95d39edd754a0e", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/tests/scenario/notes.md": "51490ded1b98b1846ca45c6b85a7a4a37115418f2224b364d86fefac3250ab72", "tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/tests/scenario/record.json": "6f654d1cfae20cc8b64f46ffe3acb8d8a8273fec818c8aa786f9adec3d71d7f6", @@ -11180,19 +11184,19 @@ "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/docker-compose.yaml": "620a47788c86c037b5eab85dbfff99a0104cf715587f4df009ff81a09af281fe", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/team/scenario/episode.yaml": "78044f0231e8df58363b88dc9b82a6a51c71c2fd7b24338c68b0060292e01add", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/team/scenario/notes.md": "ef7e4e390d37717227e00d64384a5bc6626bb85650bc03f3577ca27c03e05425", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/team/scenario/record.json": "3af94f0aef942022f05ea08afa4b2d63bb903b7bd6f93e10bda13adda74199b9", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/team/scenario/source.md": "80b2e56bc08e7b83a91a32285f5b6233a80e1dbcc4f4bcd530bdc354129f5a21", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/team/task.json": "c222b7c9a8144b73d0cd69fa0792c73f45801e3fd9340565006f5cbd0e5d5efd", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/team/task.json": "7986e06f2797d1f3ad86369284a08812ceeccdf648baa58419c4f98ed3ece952", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11205,13 +11209,13 @@ "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/task.toml": "9260dc3cbb31379278c5f1f460d6bbd5d702a352ae7a487aea47b9553a093e23", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/task.toml": "05ec7ae949ae9fffb5687f39412a666753d06454faada22c616ba3b77dd35e49", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/tests/expected.json": "b817d55a1b2283b1ed62b543c50c819614f314c116561f83c3c734e0b059f0d6", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/tests/scenario/episode.yaml": "78044f0231e8df58363b88dc9b82a6a51c71c2fd7b24338c68b0060292e01add", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/tests/scenario/notes.md": "ef7e4e390d37717227e00d64384a5bc6626bb85650bc03f3577ca27c03e05425", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/tests/scenario/record.json": "3af94f0aef942022f05ea08afa4b2d63bb903b7bd6f93e10bda13adda74199b9", @@ -11230,19 +11234,19 @@ "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/docker-compose.yaml": "fb447e4a2f24a49a53cbacbab8ce63f96a4bbb04d24d7819b08539f719bf5432", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/team/scenario/episode.yaml": "78044f0231e8df58363b88dc9b82a6a51c71c2fd7b24338c68b0060292e01add", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/team/scenario/notes.md": "ef7e4e390d37717227e00d64384a5bc6626bb85650bc03f3577ca27c03e05425", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/team/scenario/record.json": "3af94f0aef942022f05ea08afa4b2d63bb903b7bd6f93e10bda13adda74199b9", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/team/scenario/source.md": "80b2e56bc08e7b83a91a32285f5b6233a80e1dbcc4f4bcd530bdc354129f5a21", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/team/task.json": "133b8b05919e2ec9ae1005cf2c638fe1f82497ebacef4e7322dd90fb529f876f", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/team/task.json": "12b1b3adaf9abd32d7af49ce3fbcd37f1b49ca8cf21077fd3372f3fe6dd358cb", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11255,13 +11259,13 @@ "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/task.toml": "b4dc29d1c7e496ba18a707ffe4b7beb88ad6f21e4e10b65fb700040183f5a984", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/task.toml": "2f7aa1f622ed1180330e5a3742d81fba63835570dff2f6f28469dd816adf0b67", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/tests/expected.json": "1777d841a035d56b4b9f2656d5062a943d93f426ebd7170cc1de16db4c73b315", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/tests/scenario/episode.yaml": "78044f0231e8df58363b88dc9b82a6a51c71c2fd7b24338c68b0060292e01add", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/tests/scenario/notes.md": "ef7e4e390d37717227e00d64384a5bc6626bb85650bc03f3577ca27c03e05425", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/tests/scenario/record.json": "3af94f0aef942022f05ea08afa4b2d63bb903b7bd6f93e10bda13adda74199b9", @@ -11280,19 +11284,19 @@ "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/docker-compose.yaml": "53e09220a1f27d0954ebd2a978f1cd79f52cdfa873ecb35541c26dd059abcd50", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/team/scenario/episode.yaml": "78044f0231e8df58363b88dc9b82a6a51c71c2fd7b24338c68b0060292e01add", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/team/scenario/notes.md": "ef7e4e390d37717227e00d64384a5bc6626bb85650bc03f3577ca27c03e05425", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/team/scenario/record.json": "3af94f0aef942022f05ea08afa4b2d63bb903b7bd6f93e10bda13adda74199b9", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/team/scenario/source.md": "80b2e56bc08e7b83a91a32285f5b6233a80e1dbcc4f4bcd530bdc354129f5a21", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/team/task.json": "0bf6a27740d749de4ff8b48f64a19e73916bf2ddd5332b5c2b9d1be41bbbcd35", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/team/task.json": "abd7ff7c5e77b6a1548a59dd05e8344328a55319bd8c5c1b404f77c35b81e59a", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11305,13 +11309,13 @@ "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/task.toml": "d56592c5fe01478c941e4e9e905f07a7f1eeb00be1eea35245a3321e8a86d462", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/task.toml": "b097f99f787866994edfdb3ad5cc9b94b59a67b18c8643c213cab95e00f958ee", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/tests/expected.json": "ef0c794b4d9b767ccad91896e0381bbbc68db14a0bcbcc0c693144070fbeea9a", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/tests/scenario/episode.yaml": "78044f0231e8df58363b88dc9b82a6a51c71c2fd7b24338c68b0060292e01add", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/tests/scenario/notes.md": "ef7e4e390d37717227e00d64384a5bc6626bb85650bc03f3577ca27c03e05425", "tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/tests/scenario/record.json": "3af94f0aef942022f05ea08afa4b2d63bb903b7bd6f93e10bda13adda74199b9", @@ -11330,19 +11334,19 @@ "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/docker-compose.yaml": "242d6749a652613cc7d1001725458b254022e364e4ea0c3f8caba8d9aeb71f3d", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/team/scenario/episode.yaml": "167080a229b4eec22997bc0479b11b5da9a4d529d2aed55a892060d6a98eeacd", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/team/scenario/notes.md": "d6ed724138cc38cd5e1602af874b5889ac9c7e4326dd2e69a7b47d67b0de6f4e", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/team/scenario/record.json": "92855bdc9b99d75e8ae27e92baf5d4624b9cd9c303fa1c5afdfe79daa852145a", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/team/scenario/source.md": "b5e1db6a3dd8b394be32576022c32b0cc77e028a782c758cad26bb35ea0dbe3b", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/team/task.json": "b9a36d9ecf2822b8ec71227214802033e9c93116d823f3fb7149cb3e4098ffb4", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/team/task.json": "d870973dd6afeb4ec4b0da09841729d5bcdf989bd3189d7e98e5f36a35dc399f", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11355,13 +11359,13 @@ "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/task.toml": "6b6596a1510a96a515b94fca88f64f977e5fda18aba3e9cb350a999336ebde98", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/task.toml": "9bb2cf57a05b4b38fe846bed087c04e5269b4aaf7f345a10a4a68d2df1708b28", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/tests/expected.json": "a578a7daa451b6059fa202a3f840a0c28acfdd4dc4aed35c8867823fe36f0715", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/tests/scenario/episode.yaml": "167080a229b4eec22997bc0479b11b5da9a4d529d2aed55a892060d6a98eeacd", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/tests/scenario/notes.md": "d6ed724138cc38cd5e1602af874b5889ac9c7e4326dd2e69a7b47d67b0de6f4e", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/tests/scenario/record.json": "92855bdc9b99d75e8ae27e92baf5d4624b9cd9c303fa1c5afdfe79daa852145a", @@ -11380,19 +11384,19 @@ "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/docker-compose.yaml": "004da048aea7486f27912632768425573a64a4d969929a3f879ada79ec552a1e", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/team/scenario/episode.yaml": "8ae3cf2b43293bdf3a3139afd04598034b3abc3ca5f49942ed878711b415d9ea", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/team/scenario/notes.md": "3d7bdf15fa4f3cb64718d14b65a7790078c1acdc3558d9670410df91752960d8", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/team/scenario/record.json": "520f9cc3f72be214861b6aac5cacf2d05b67add1f0c54a76e33d81e614a28ec9", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/team/scenario/source.md": "1c3a0e9279f7e0c6315167801a4d43843084839021e6778527696eeee3fb1bdf", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/team/task.json": "31f76d0eb6ee63e4899a273083464ee44885d804cf0c8feb51d733092166b285", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/team/task.json": "d40b3bd2480e7bfdce17ec62905313ede8d9b799313ce37c0c1c3ae26501ce6d", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11405,13 +11409,13 @@ "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/task.toml": "f2318e28a7cda9d6046e57e4c94ee039c13488378acd7dc37f818cf55c70c40d", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/task.toml": "9b76fc9cbe688aeb67e5e8d2309f4a9e3ff9b9eb6a9899e180203fe18d23f9f1", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/tests/expected.json": "7b6aadca050d8bc67c2ed52ff305792369d744a2ec048afacc2e26998f1fa1b1", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/tests/scenario/episode.yaml": "8ae3cf2b43293bdf3a3139afd04598034b3abc3ca5f49942ed878711b415d9ea", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/tests/scenario/notes.md": "3d7bdf15fa4f3cb64718d14b65a7790078c1acdc3558d9670410df91752960d8", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/tests/scenario/record.json": "520f9cc3f72be214861b6aac5cacf2d05b67add1f0c54a76e33d81e614a28ec9", @@ -11430,19 +11434,19 @@ "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/docker-compose.yaml": "5c3e0d6ab777723a3bb3f1890eeb211d6d303a788af372a747eb370f01ff8977", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/team/scenario/episode.yaml": "167080a229b4eec22997bc0479b11b5da9a4d529d2aed55a892060d6a98eeacd", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/team/scenario/notes.md": "d6ed724138cc38cd5e1602af874b5889ac9c7e4326dd2e69a7b47d67b0de6f4e", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/team/scenario/record.json": "92855bdc9b99d75e8ae27e92baf5d4624b9cd9c303fa1c5afdfe79daa852145a", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/team/scenario/source.md": "b5e1db6a3dd8b394be32576022c32b0cc77e028a782c758cad26bb35ea0dbe3b", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/team/task.json": "f8ec53cae31688b4f67b2053a71328574f51854dc056225670c1d703685d30db", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/team/task.json": "2832fdef77f591e6e1d80c62e7c94484099dabb3f74b936406c43101ecc14fbc", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11455,13 +11459,13 @@ "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/task.toml": "7fb363743881effaf23d10128567aa827f1dea96e75cedadf36951d23195c153", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/task.toml": "6fb336237c827dd8fa05ef86660859e0aa846109e363296126dd30efc008d3c2", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/tests/expected.json": "f7d4137515d6b0ac02678c122e6b8e72bd3a8d8ec7ca097f0e1bf2bebfeccab7", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/tests/scenario/episode.yaml": "167080a229b4eec22997bc0479b11b5da9a4d529d2aed55a892060d6a98eeacd", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/tests/scenario/notes.md": "d6ed724138cc38cd5e1602af874b5889ac9c7e4326dd2e69a7b47d67b0de6f4e", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/tests/scenario/record.json": "92855bdc9b99d75e8ae27e92baf5d4624b9cd9c303fa1c5afdfe79daa852145a", @@ -11480,19 +11484,19 @@ "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/docker-compose.yaml": "5d790419e65bc6af40ad6ad091fe25683f2200da43aca4e3d488b54fc2559f71", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/team/scenario/episode.yaml": "167080a229b4eec22997bc0479b11b5da9a4d529d2aed55a892060d6a98eeacd", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/team/scenario/notes.md": "d6ed724138cc38cd5e1602af874b5889ac9c7e4326dd2e69a7b47d67b0de6f4e", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/team/scenario/record.json": "92855bdc9b99d75e8ae27e92baf5d4624b9cd9c303fa1c5afdfe79daa852145a", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/team/scenario/source.md": "b5e1db6a3dd8b394be32576022c32b0cc77e028a782c758cad26bb35ea0dbe3b", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/team/task.json": "36181c870b857b9f54d397d541088ebcc9331bc94a757ff0f6d71c2540f394cb", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/team/task.json": "3b4bf11b8fe6b3666035f31d6ab7b1a0af62b3420f052c383a50793bb0123b54", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11505,13 +11509,13 @@ "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/task.toml": "38f01c3d8ba7c5953b8abfa7704d36cf89c59f886adb0eded385b120ce119758", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/task.toml": "1e0cb441a20c68cc4710bbe91e5d9ea4622402c2276c2f2a0c0d8b3376b6b7db", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/tests/expected.json": "98003ccf5ae04a0299df5b08c9c265eed4355c355072aad0dfb462f31b7a5c34", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/tests/scenario/episode.yaml": "167080a229b4eec22997bc0479b11b5da9a4d529d2aed55a892060d6a98eeacd", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/tests/scenario/notes.md": "d6ed724138cc38cd5e1602af874b5889ac9c7e4326dd2e69a7b47d67b0de6f4e", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/tests/scenario/record.json": "92855bdc9b99d75e8ae27e92baf5d4624b9cd9c303fa1c5afdfe79daa852145a", @@ -11530,19 +11534,19 @@ "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/docker-compose.yaml": "1c4b13c816b80a6cfb9712287560e68c19fb4e88e6fdf958bdcd77f4123a9f25", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/team/scenario/episode.yaml": "167080a229b4eec22997bc0479b11b5da9a4d529d2aed55a892060d6a98eeacd", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/team/scenario/notes.md": "d6ed724138cc38cd5e1602af874b5889ac9c7e4326dd2e69a7b47d67b0de6f4e", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/team/scenario/record.json": "92855bdc9b99d75e8ae27e92baf5d4624b9cd9c303fa1c5afdfe79daa852145a", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/team/scenario/source.md": "b5e1db6a3dd8b394be32576022c32b0cc77e028a782c758cad26bb35ea0dbe3b", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/team/task.json": "72f49b16b04f62e77b47a174c8ec85390eec83a8df0af5246c692013810528f7", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/team/task.json": "ae404ca1b5cc51ab09157607704443d1ca9aad76253ff4fe6236268dc463b49d", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11555,13 +11559,13 @@ "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/task.toml": "aa21af0ba9be6e8af34ae417a9d75bb985327669dd1528454456b95054b00038", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/task.toml": "1b5b7a19c8cd7859eaa57bb64ec61897e2e0de3a28a1c6f77f369265523c4c54", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/tests/expected.json": "344b4f37d9cb1109c6855e024e213dc7bc9a7171847cfb49f5ccce3806cace03", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/tests/scenario/episode.yaml": "167080a229b4eec22997bc0479b11b5da9a4d529d2aed55a892060d6a98eeacd", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/tests/scenario/notes.md": "d6ed724138cc38cd5e1602af874b5889ac9c7e4326dd2e69a7b47d67b0de6f4e", "tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/tests/scenario/record.json": "92855bdc9b99d75e8ae27e92baf5d4624b9cd9c303fa1c5afdfe79daa852145a", @@ -11580,19 +11584,19 @@ "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/docker-compose.yaml": "1e5bfaa2a9fa2b60c8f790de8d11c26ba238b1375f09c4d4a42f12780fc80b06", - "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/team/scenario/episode.yaml": "cf9bf79c6bf4a86f9a760235521d933cbe8994f761d61eb8b7a552b6c9f896be", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/team/scenario/notes.md": "96e26170a0a9f53df0c7ab8ab2edb723c6b6e6849a0150cf19c5750f454145b1", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/team/scenario/record.json": "96463fd0c0d3e1607eb339efbf0aff15dbf76e4e198f199dc804ef5df5f01f81", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/team/scenario/source.md": "11fbc3e0e7224dbc87983fea1f1538050bd77896bd831ceddcdbeaa765f1e12e", - "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/team/task.json": "65f2f15351c4ffecaa51e066fa332c3770ba798cd5824ba8a46787152cd4dc21", + "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/team/task.json": "da91906b7a34bb037c645a67e90e5329371f60fb18db1b024f1df959a180a622", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11605,13 +11609,13 @@ "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/task.toml": "f5fe3ef2fbf1d972db28b815b71fcedc1682b030bd6cedfcfa63bc056406d0a8", + "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/task.toml": "cf451a95b15b6af7a2c46283d22414f062eb04156348bb71281dff46acad9bbc", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/tests/expected.json": "cca0d2560df3608f2d6c1b85decd204a02f9c8b09d84d772df0b9792b267e088", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/tests/scenario/episode.yaml": "cf9bf79c6bf4a86f9a760235521d933cbe8994f761d61eb8b7a552b6c9f896be", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/tests/scenario/notes.md": "96e26170a0a9f53df0c7ab8ab2edb723c6b6e6849a0150cf19c5750f454145b1", "tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/tests/scenario/record.json": "96463fd0c0d3e1607eb339efbf0aff15dbf76e4e198f199dc804ef5df5f01f81", @@ -11630,19 +11634,19 @@ "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/docker-compose.yaml": "11d200124b4dae5477652acc9b43856a1af7804c28e3f99e6b79b9e7778e7ada", - "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/team/scenario/episode.yaml": "0b2945f8b6f8732f31d72995fb6b8675036040823fb3f028a9933685d4dcb1c6", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/team/scenario/notes.md": "6402471082189ec3a9616ce0634b4a6840b5e39d644f87e46e45e660425131fd", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/team/scenario/record.json": "56ffe357db191984aa52520fac26be180c56aa1e1d660f8d4ad72b6b842e9c78", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/team/scenario/source.md": "35119d2fd403306423c058207edcd46105f95182ade6d7c0c066cd246ad538df", - "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/team/task.json": "88603e71eb6b383f0b8604d4cf899ae7950b8ee0518cc03243a531aa0e263be4", + "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/team/task.json": "9bd4bfdb7ff465c58ac869c600760253349c225dc6fd9461828ba34a3bdbdb9b", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11655,13 +11659,13 @@ "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/task.toml": "3cffa36e4f267c6c89a51c4d839739d25b2f54cff91ce1cc2c3ec81bd46a36a3", + "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/task.toml": "8f1dda3d022331e77c743423b2c1be40ab8b1f4670d415193c906c4bb80e8e37", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/tests/expected.json": "e9e4b3c5a5cfb47c9a22251c126496b7331cdcdc43008a6fb24ac0fb76ffee65", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/tests/scenario/episode.yaml": "0b2945f8b6f8732f31d72995fb6b8675036040823fb3f028a9933685d4dcb1c6", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/tests/scenario/notes.md": "6402471082189ec3a9616ce0634b4a6840b5e39d644f87e46e45e660425131fd", "tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/tests/scenario/record.json": "56ffe357db191984aa52520fac26be180c56aa1e1d660f8d4ad72b6b842e9c78", @@ -11680,19 +11684,19 @@ "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/docker-compose.yaml": "965af5c723134f649e88384c472ac1ff5f040559b77dd71cca7d04890d913647", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/team/scenario/episode.yaml": "cf9bf79c6bf4a86f9a760235521d933cbe8994f761d61eb8b7a552b6c9f896be", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/team/scenario/notes.md": "96e26170a0a9f53df0c7ab8ab2edb723c6b6e6849a0150cf19c5750f454145b1", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/team/scenario/record.json": "96463fd0c0d3e1607eb339efbf0aff15dbf76e4e198f199dc804ef5df5f01f81", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/team/scenario/source.md": "11fbc3e0e7224dbc87983fea1f1538050bd77896bd831ceddcdbeaa765f1e12e", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/team/task.json": "f9e5811e6b1b703386b6a5c35bb57e21c2e903c11384b459b647f145309e7ef8", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/team/task.json": "271b3bc6f0ade532b40c7126d1d7f8a53289a51de63e248ed6404dbfdbb2c92a", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11705,13 +11709,13 @@ "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/task.toml": "2d94802cd9b4e8ea7389ce1ebe5a3851b5c85c98e8562bc59bcec9b6f8a7d165", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/task.toml": "dbc59478508e2563adb4ce9fc199f0f3e7ab90851126bc3a48e25823260ba063", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/tests/expected.json": "7e197811a02198d28b49ba44a75f6ab852624b4a7f899ce93249222520f81e96", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/tests/scenario/episode.yaml": "cf9bf79c6bf4a86f9a760235521d933cbe8994f761d61eb8b7a552b6c9f896be", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/tests/scenario/notes.md": "96e26170a0a9f53df0c7ab8ab2edb723c6b6e6849a0150cf19c5750f454145b1", "tasks/ci-taking-initiative-s-refund-window--r5-test-s0/tests/scenario/record.json": "96463fd0c0d3e1607eb339efbf0aff15dbf76e4e198f199dc804ef5df5f01f81", @@ -11730,19 +11734,19 @@ "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/docker-compose.yaml": "fa33916037719a015a9322cf5921369a16f47982317b1a2e0b48396fda185ddd", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/team/scenario/episode.yaml": "cf9bf79c6bf4a86f9a760235521d933cbe8994f761d61eb8b7a552b6c9f896be", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/team/scenario/notes.md": "96e26170a0a9f53df0c7ab8ab2edb723c6b6e6849a0150cf19c5750f454145b1", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/team/scenario/record.json": "96463fd0c0d3e1607eb339efbf0aff15dbf76e4e198f199dc804ef5df5f01f81", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/team/scenario/source.md": "11fbc3e0e7224dbc87983fea1f1538050bd77896bd831ceddcdbeaa765f1e12e", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/team/task.json": "bc0e5688ff3477e62be6656e9b6243d7d2af97840a88825bace3185f9587632e", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/team/task.json": "c39093e673f6059743c5114ee56aa35da9165b1347b73f6ffa1b047bbe272eba", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11755,13 +11759,13 @@ "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/task.toml": "40ae6b4d8f87c392703856efc769a62dcd8a6c6a79784ba2919da41755e973cc", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/task.toml": "bf46771c19589da7b2ad325389fa2bd562706d08f178857ef9419456ed396026", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/tests/expected.json": "2a9585c797d433b8cd270421658dce42f2e19868aa8eff6ec6ee9d6d8cd74d38", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/tests/scenario/episode.yaml": "cf9bf79c6bf4a86f9a760235521d933cbe8994f761d61eb8b7a552b6c9f896be", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/tests/scenario/notes.md": "96e26170a0a9f53df0c7ab8ab2edb723c6b6e6849a0150cf19c5750f454145b1", "tasks/ci-taking-initiative-s-refund-window--r5-test-s1/tests/scenario/record.json": "96463fd0c0d3e1607eb339efbf0aff15dbf76e4e198f199dc804ef5df5f01f81", @@ -11780,19 +11784,19 @@ "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/docker-compose.yaml": "219ceec4411879f09d7f66d4b9ee7c963adf5662c07fadf06e2d6ac4ab5158d9", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/team/scenario/episode.yaml": "cf9bf79c6bf4a86f9a760235521d933cbe8994f761d61eb8b7a552b6c9f896be", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/team/scenario/notes.md": "96e26170a0a9f53df0c7ab8ab2edb723c6b6e6849a0150cf19c5750f454145b1", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/team/scenario/record.json": "96463fd0c0d3e1607eb339efbf0aff15dbf76e4e198f199dc804ef5df5f01f81", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/team/scenario/source.md": "11fbc3e0e7224dbc87983fea1f1538050bd77896bd831ceddcdbeaa765f1e12e", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/team/task.json": "39b857e4ab8ce24b68a3c0954737a317bb856ece710a8c95b8007aa622291f68", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/team/task.json": "5a4e90ef65f413d3d863e28d83faaa15ea9ca453dc275dc9a483a0a7c0f52779", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11805,13 +11809,13 @@ "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/task.toml": "3c25f0b568abf552df99c2b0d1134bc08da2aeb6d5ae84bc09921f2fefec4391", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/task.toml": "59bbdc4752f84c0cd7e2c13d0a806a1ae53573ca3b9be7accebabee05f2a3c90", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/tests/expected.json": "8ed1f4f901fc01c88ef79f0c201d4085d87bd638c719657dfc2d8cd832b58e03", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/tests/scenario/episode.yaml": "cf9bf79c6bf4a86f9a760235521d933cbe8994f761d61eb8b7a552b6c9f896be", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/tests/scenario/notes.md": "96e26170a0a9f53df0c7ab8ab2edb723c6b6e6849a0150cf19c5750f454145b1", "tasks/ci-taking-initiative-s-refund-window--r5-test-s2/tests/scenario/record.json": "96463fd0c0d3e1607eb339efbf0aff15dbf76e4e198f199dc804ef5df5f01f81", @@ -11830,19 +11834,19 @@ "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/docker-compose.yaml": "e2e7251d8d7b0588ce761ed59d75a6b1585667a9c545767622979cb02a54abca", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/team/scenario/episode.yaml": "5f53ac0d1de61c183a53c2b04c2b047c5ebb9a01269336b0b1dfa99b09423e24", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/team/scenario/notes.md": "d17bfa3ce836d84d5c48743149b7c3c01f2268884323659b31265fc4c4eaa512", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/team/scenario/record.json": "ad8813f2fd4785f1d3eaf229f8ef76126a1c16d3e1484f79e0c2c064fc4018d2", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/team/scenario/source.md": "cf382004140974fe011147c622f638a8baa62c0ff45bface32eed79f1fa9a720", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/team/task.json": "8f1d4164d4a8738e2262201fe8ead867200d5e79ca1332c83c3cb54e7161f4f9", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/team/task.json": "adb1387652a6f7d3b090250f60dc1c18b5a599a8cb93832ecb149cfc3ab0a538", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11855,13 +11859,13 @@ "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/task.toml": "77d2964abeb0e675dd91ad26ba32dca78e9b34cda5e4cf91cb71bd9464e8951c", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/task.toml": "0cbccd77f48bee3ce196db1751f5f33f37672fe9431590a784970faffb95e04f", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/tests/expected.json": "68a4fb8337de8a9a076d5adace571291575cb7896491cd2b8a3cc04ce1243010", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/tests/scenario/episode.yaml": "5f53ac0d1de61c183a53c2b04c2b047c5ebb9a01269336b0b1dfa99b09423e24", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/tests/scenario/notes.md": "d17bfa3ce836d84d5c48743149b7c3c01f2268884323659b31265fc4c4eaa512", "tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/tests/scenario/record.json": "ad8813f2fd4785f1d3eaf229f8ef76126a1c16d3e1484f79e0c2c064fc4018d2", @@ -11880,19 +11884,19 @@ "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/docker-compose.yaml": "23320da35723d761a3ade497f7ac91e720857cf3dc3a08b1748d2e71ca071789", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/team/scenario/episode.yaml": "08a4217672d0a0c4d289c05b91dc0ef7ff0e95427c5adea1a7c751b21731faba", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/team/scenario/notes.md": "c1c00d77af6f6118f46b66406f37230a9e43776d125df9b9d7542e359ee20901", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/team/scenario/record.json": "88236c8ecca5df75c143b654825dd6b51072543d279367951d7baff4c429629d", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/team/scenario/source.md": "cf382004140974fe011147c622f638a8baa62c0ff45bface32eed79f1fa9a720", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/team/task.json": "cb289fadfbf9884e6db41c47a9b11845d9c0aad1fdf9e63ca4bf771d730b1711", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/team/task.json": "3836d7431378e8238f22911fcc1a01616367a5f95847a31e79c252ca685d8eab", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11905,13 +11909,13 @@ "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/task.toml": "42496c1646db4b69ff2b96cd7b2ca97251f755b73cc5a36a5266f50cbcab93e1", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/task.toml": "f39718a30f0119ae71bc13442c2a89dfb63a7408072956b03a78be71d1df3c96", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/tests/expected.json": "3b70eff82bb481aacbe1ca2cde170f2abb7d5b0050b91812dbff8360276e4511", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/tests/scenario/episode.yaml": "08a4217672d0a0c4d289c05b91dc0ef7ff0e95427c5adea1a7c751b21731faba", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/tests/scenario/notes.md": "c1c00d77af6f6118f46b66406f37230a9e43776d125df9b9d7542e359ee20901", "tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/tests/scenario/record.json": "88236c8ecca5df75c143b654825dd6b51072543d279367951d7baff4c429629d", @@ -11930,19 +11934,19 @@ "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/docker-compose.yaml": "09b63c1dc9d1c41e2a6f0a8e65de52e522a123f46cba98c9a4add640e77b2043", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/team/scenario/episode.yaml": "5f53ac0d1de61c183a53c2b04c2b047c5ebb9a01269336b0b1dfa99b09423e24", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/team/scenario/notes.md": "d17bfa3ce836d84d5c48743149b7c3c01f2268884323659b31265fc4c4eaa512", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/team/scenario/record.json": "ad8813f2fd4785f1d3eaf229f8ef76126a1c16d3e1484f79e0c2c064fc4018d2", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/team/scenario/source.md": "cf382004140974fe011147c622f638a8baa62c0ff45bface32eed79f1fa9a720", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/team/task.json": "10ca750d010ba1c65a10de911a6bb44897d9f40cae332b4b3f8b4e6b17e98402", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/team/task.json": "94865524c32bae8e6575b96be6c1a7a17880725b59e11e26342850251a818cf9", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -11955,13 +11959,13 @@ "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/task.toml": "695c66c8916619708d2e87b12d42910729d99435ae70c83c1fb6411d79269b05", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/task.toml": "45dae07639c0e8dce870a16fba24e6ac08ab435a6b2a85a4ea0fb49d6d38ed5b", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/tests/expected.json": "202c782ee4dae674bea9fc784247ee753543b57d827c82ef4a589790061e9172", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/tests/scenario/episode.yaml": "5f53ac0d1de61c183a53c2b04c2b047c5ebb9a01269336b0b1dfa99b09423e24", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/tests/scenario/notes.md": "d17bfa3ce836d84d5c48743149b7c3c01f2268884323659b31265fc4c4eaa512", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/tests/scenario/record.json": "ad8813f2fd4785f1d3eaf229f8ef76126a1c16d3e1484f79e0c2c064fc4018d2", @@ -11980,19 +11984,19 @@ "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/docker-compose.yaml": "f8676a21a4fac88ed5a92f1d7c24844a4a449ccb5d756622fb2df9db9be5ba5e", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/team/scenario/episode.yaml": "5f53ac0d1de61c183a53c2b04c2b047c5ebb9a01269336b0b1dfa99b09423e24", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/team/scenario/notes.md": "d17bfa3ce836d84d5c48743149b7c3c01f2268884323659b31265fc4c4eaa512", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/team/scenario/record.json": "ad8813f2fd4785f1d3eaf229f8ef76126a1c16d3e1484f79e0c2c064fc4018d2", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/team/scenario/source.md": "cf382004140974fe011147c622f638a8baa62c0ff45bface32eed79f1fa9a720", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/team/task.json": "831aadcea390ad9e6f0ce02aa2e685d7fe722f6e5d1bc5cfbf7506aae268f37c", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/team/task.json": "4a8323b2210db4993efaa625a1ff951fd16062be0caac02bd2706302d663f366", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12005,13 +12009,13 @@ "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/task.toml": "b2a3d55ef8c9ecea707ab6d3c0cf07e848c6e89c1609f64069a8ed272befb349", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/task.toml": "5d7e5f67ffb8e85fed9c1dad23c306d5e00da5625346f495fa2a37b737149733", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/tests/expected.json": "4e49f47ea409c9c7b7c9e3ef89b2cb85c33a31a8cf53bb5d3b1dbe293d58bf3f", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/tests/scenario/episode.yaml": "5f53ac0d1de61c183a53c2b04c2b047c5ebb9a01269336b0b1dfa99b09423e24", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/tests/scenario/notes.md": "d17bfa3ce836d84d5c48743149b7c3c01f2268884323659b31265fc4c4eaa512", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/tests/scenario/record.json": "ad8813f2fd4785f1d3eaf229f8ef76126a1c16d3e1484f79e0c2c064fc4018d2", @@ -12030,19 +12034,19 @@ "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/docker-compose.yaml": "932c007eb5d51ba78fa149cde8839baa57eda7e00199e00d0f306f5330db3a7a", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/team/scenario/episode.yaml": "5f53ac0d1de61c183a53c2b04c2b047c5ebb9a01269336b0b1dfa99b09423e24", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/team/scenario/notes.md": "d17bfa3ce836d84d5c48743149b7c3c01f2268884323659b31265fc4c4eaa512", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/team/scenario/record.json": "ad8813f2fd4785f1d3eaf229f8ef76126a1c16d3e1484f79e0c2c064fc4018d2", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/team/scenario/source.md": "cf382004140974fe011147c622f638a8baa62c0ff45bface32eed79f1fa9a720", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/team/task.json": "3bef681c44cf1987331e441af58d1c5a01b620102350601dbb12df29d1d9a925", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/team/task.json": "195066e6ad5c15a20d778e8f3ade94a2b3073621b8d3cda66db4246c851f533c", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12055,13 +12059,13 @@ "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/task.toml": "71b62638990cf317ca5276e9881d8f7fd7de81aaaa509f1623bc1dd12f95a783", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/task.toml": "b013420085d9b448f4d67db64bc66aad979fd7d313b15d1c7754c6df48038f29", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/tests/expected.json": "ac2132d3cde53b00c3db91557409ee23355c3583f048b8794902aa30b68a9007", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/tests/scenario/episode.yaml": "5f53ac0d1de61c183a53c2b04c2b047c5ebb9a01269336b0b1dfa99b09423e24", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/tests/scenario/notes.md": "d17bfa3ce836d84d5c48743149b7c3c01f2268884323659b31265fc4c4eaa512", "tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/tests/scenario/record.json": "ad8813f2fd4785f1d3eaf229f8ef76126a1c16d3e1484f79e0c2c064fc4018d2", @@ -12080,19 +12084,19 @@ "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/docker-compose.yaml": "8456b51608029f01529e75e074f9275c3c55c85d40bf1b4847e5b1794b962b6c", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/team/scenario/episode.yaml": "f66655e590c635df166bd8f3fcc27bc7db3d6056dc4008fe91e5487024981e48", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/team/scenario/notes.md": "06b1580d9dec534e6815c184ec48ae0b194460608a434944fbf283486111a3a0", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/team/scenario/record.json": "877f5d5982e90a83a364a85e71665c6fc46d1645cbaa2f5014273907ea64818a", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/team/scenario/source.md": "aa1b4c1e0ebab3aaaac26723c87ed082c4e6b8a1c05b8878cd3dd0af296920c8", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/team/task.json": "c4d02e2e6f3997c482e8763b5347d652b52fc8e7b00bdee3e9aa590574cbca08", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/team/task.json": "63b7acf4e7e045ee4fc020ebd263a8ea00af7d845ee8bfba3b2a8464396aab47", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12105,13 +12109,13 @@ "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/task.toml": "f339e77f479491f31589651aade45e2d138474af1052a6b9fe4058ced6e68540", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/task.toml": "040e7183f8e6da0c4d4daa5a435e4738ee36d91f568e7aba51de07f36a8210dd", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/tests/expected.json": "50d4b48789f4d0f348572fd23b60ce53db2f64e8df05f3ef4e5f01dd2f9e567c", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/tests/scenario/episode.yaml": "f66655e590c635df166bd8f3fcc27bc7db3d6056dc4008fe91e5487024981e48", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/tests/scenario/notes.md": "06b1580d9dec534e6815c184ec48ae0b194460608a434944fbf283486111a3a0", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/tests/scenario/record.json": "877f5d5982e90a83a364a85e71665c6fc46d1645cbaa2f5014273907ea64818a", @@ -12130,19 +12134,19 @@ "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/docker-compose.yaml": "564a270c74946c48a4e65a98b5fe09cfd0a4cd50c620e1d727707d5ec6558016", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/team/scenario/episode.yaml": "b92181c65feb88bcd4b277a6b5c3178341bd2bd847dcc667e7d5186001e90945", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/team/scenario/notes.md": "a3b9947f25c5b980d21ccd14105f25a711d891ee0caf76aca2fcd4e18303302d", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/team/scenario/record.json": "fd043d81ac7b40a7b0531ce17b8b9689d12efc2a364082018ee9576812f9f3c6", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/team/scenario/source.md": "aa1b4c1e0ebab3aaaac26723c87ed082c4e6b8a1c05b8878cd3dd0af296920c8", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/team/task.json": "3500e436b1a156dafc9d94474df902c76c7cdb05159464925bef7114cf6b15b7", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/team/task.json": "5a77f0f7bf28096fd33bbfb875abe06d5b1684d147aa47d4b03cc0115f2226f0", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12155,13 +12159,13 @@ "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/task.toml": "d9f940c3465c362aa8690481b0b7f01cdc10b86f1eb80ccfd09a35709d31a612", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/task.toml": "745fa7b0a8f383dd0f200ac4637fc921a1f5f30a365a8b3a42c27d8470aa2711", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/tests/expected.json": "5d750c9ab7bedd853f6a1a476469d17d7622278995f218f1d5debff4bd10155e", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/tests/scenario/episode.yaml": "b92181c65feb88bcd4b277a6b5c3178341bd2bd847dcc667e7d5186001e90945", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/tests/scenario/notes.md": "a3b9947f25c5b980d21ccd14105f25a711d891ee0caf76aca2fcd4e18303302d", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/tests/scenario/record.json": "fd043d81ac7b40a7b0531ce17b8b9689d12efc2a364082018ee9576812f9f3c6", @@ -12180,19 +12184,19 @@ "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/docker-compose.yaml": "75d37451d3b60def9ba1de9cf467e2996e5259f1c588ba817711db48380d7a5f", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/team/scenario/episode.yaml": "f66655e590c635df166bd8f3fcc27bc7db3d6056dc4008fe91e5487024981e48", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/team/scenario/notes.md": "06b1580d9dec534e6815c184ec48ae0b194460608a434944fbf283486111a3a0", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/team/scenario/record.json": "877f5d5982e90a83a364a85e71665c6fc46d1645cbaa2f5014273907ea64818a", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/team/scenario/source.md": "aa1b4c1e0ebab3aaaac26723c87ed082c4e6b8a1c05b8878cd3dd0af296920c8", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/team/task.json": "7a06b0b8417ddff8cf864222479c19554eadd5799d4102f37a9fd884d5575826", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/team/task.json": "39c953dfe6b1be72f3e2691de38a71588d750388a78a856fb8e9d85691cb9ca8", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12205,13 +12209,13 @@ "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/task.toml": "e1a0a3385cca040da6dac2b8f436ca314ab46964f1240304659ebb73ea0b4f8f", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/task.toml": "22fe87a85de995040017f70eb172a3e9161caf620d3021bccf984398260c4198", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/tests/expected.json": "a308f62160066efa14d59c8245cf4e5fc3d8896a9b4309a3c97089a5e4c593a6", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/tests/scenario/episode.yaml": "f66655e590c635df166bd8f3fcc27bc7db3d6056dc4008fe91e5487024981e48", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/tests/scenario/notes.md": "06b1580d9dec534e6815c184ec48ae0b194460608a434944fbf283486111a3a0", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/tests/scenario/record.json": "877f5d5982e90a83a364a85e71665c6fc46d1645cbaa2f5014273907ea64818a", @@ -12230,19 +12234,19 @@ "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/docker-compose.yaml": "d53569766fae51c1ec90692716344e967922301bb5e3411dabf3cecdeac56765", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/team/scenario/episode.yaml": "f66655e590c635df166bd8f3fcc27bc7db3d6056dc4008fe91e5487024981e48", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/team/scenario/notes.md": "06b1580d9dec534e6815c184ec48ae0b194460608a434944fbf283486111a3a0", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/team/scenario/record.json": "877f5d5982e90a83a364a85e71665c6fc46d1645cbaa2f5014273907ea64818a", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/team/scenario/source.md": "aa1b4c1e0ebab3aaaac26723c87ed082c4e6b8a1c05b8878cd3dd0af296920c8", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/team/task.json": "dd3082fcf68a3c8a28445b471ae3f00d5add492e63a04d7df168fb1240b8d928", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/team/task.json": "ea28c86c84a494c1dbf5f9546289ba41f5ad17ab3de5c385d9ec8b38e661b123", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12255,13 +12259,13 @@ "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/task.toml": "4cee0ccb6e63ffb51f148ebe8ec5e19069b56731128773809bc7d1b64972b487", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/task.toml": "4a80ce5c7121a44225e74863761daf9b9a9dde6efcd22712bc392b988d9251ed", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/tests/expected.json": "2b7835110da31c9bd3c70e0a2ab067e4a63c071448fe5b81dcf6d27728d91969", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/tests/scenario/episode.yaml": "f66655e590c635df166bd8f3fcc27bc7db3d6056dc4008fe91e5487024981e48", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/tests/scenario/notes.md": "06b1580d9dec534e6815c184ec48ae0b194460608a434944fbf283486111a3a0", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/tests/scenario/record.json": "877f5d5982e90a83a364a85e71665c6fc46d1645cbaa2f5014273907ea64818a", @@ -12280,19 +12284,19 @@ "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/docker-compose.yaml": "7a66853ae0d4c13f5e854010e90f610a33049845e80344a9262f7819aa2f337b", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/team/scenario/episode.yaml": "f66655e590c635df166bd8f3fcc27bc7db3d6056dc4008fe91e5487024981e48", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/team/scenario/notes.md": "06b1580d9dec534e6815c184ec48ae0b194460608a434944fbf283486111a3a0", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/team/scenario/record.json": "877f5d5982e90a83a364a85e71665c6fc46d1645cbaa2f5014273907ea64818a", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/team/scenario/source.md": "aa1b4c1e0ebab3aaaac26723c87ed082c4e6b8a1c05b8878cd3dd0af296920c8", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/team/task.json": "87ca7ec4014f77304752fcb8ef9e58b0158fb74111a14e971c1d8eaf51c1d2a3", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/team/task.json": "bd3a175bc0813572e8f7fa754f3f35e5605da7b82aa5fda18969b5432bc729b9", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12305,13 +12309,13 @@ "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/task.toml": "21071bf56cf893367282969b1c7a8209f71ccd846a4dba497cfc35e80f1910ce", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/task.toml": "d762bffccfc38c9170a85db73016414e2fd7c9709afc897c3c0a325c81012262", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/tests/expected.json": "302c0b309a243bb3ae5762704b4497f71faef0a9f20776971fa450305359176d", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/tests/scenario/episode.yaml": "f66655e590c635df166bd8f3fcc27bc7db3d6056dc4008fe91e5487024981e48", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/tests/scenario/notes.md": "06b1580d9dec534e6815c184ec48ae0b194460608a434944fbf283486111a3a0", "tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/tests/scenario/record.json": "877f5d5982e90a83a364a85e71665c6fc46d1645cbaa2f5014273907ea64818a", @@ -12330,19 +12334,19 @@ "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/docker-compose.yaml": "b8233a5e12190dcb58abf34d79172d9c8aa4defb15d651ce3eb3c78136f17d31", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/team/scenario/episode.yaml": "c8d24e0cc2241b16714c8cad46969825cf98670b73373a9ba6c5ac281359c567", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/team/scenario/notes.md": "14e46a9924208c5baf7fbe66202226bfdaa52aa31aaf6c2e3001a8c964dd95d3", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/team/scenario/record.json": "7f523ef21d077af793096d50ab7e6b7b97af7496c4768293423d503f93002f72", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/team/scenario/source.md": "9220fb7af7facac32fa82caae13a50a678a55cccb6087d7041457a3511f5dedf", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/team/task.json": "093a576e237862dd2ccf55e0dd2bf915c593adae20d6ca456ffae57b1a68bc1a", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/team/task.json": "cecea41a1b1522d80f53ec7d1e0c605489529055cde5f9c9b42e7962cbaa4524", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12355,13 +12359,13 @@ "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/task.toml": "767ed9294acdd3c19f743c360f32e0d0f0d30af2f080a96ee4d2b81d0d278d35", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/task.toml": "0a33d5c1c5b248072310135e13f5787308508ffe6c2ccc4e6e68bd3283bcd365", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/tests/expected.json": "da7621f6bd2ce8672be822cdad0f53e963bd1b22d797fae5e1be5518b83a8022", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/tests/scenario/episode.yaml": "c8d24e0cc2241b16714c8cad46969825cf98670b73373a9ba6c5ac281359c567", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/tests/scenario/notes.md": "14e46a9924208c5baf7fbe66202226bfdaa52aa31aaf6c2e3001a8c964dd95d3", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/tests/scenario/record.json": "7f523ef21d077af793096d50ab7e6b7b97af7496c4768293423d503f93002f72", @@ -12380,19 +12384,19 @@ "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/docker-compose.yaml": "975255b9f45da373d29b08736b6bc1c183860f2965fad506f4c718334bc53586", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/team/scenario/episode.yaml": "0e851a1e9e4bb7bfc714ef546eb056576d128685a626ea50700ed76d9dbdbd5e", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/team/scenario/notes.md": "af0afad9cd9dcd9d74e4ed418f96be8b4d49ba65f6253ffed24bc0a86e0a3f30", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/team/scenario/record.json": "e51b9d9b56c506094e88d19895dd79b3372a7cf757852928427b8e20d0883c8d", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/team/scenario/source.md": "9220fb7af7facac32fa82caae13a50a678a55cccb6087d7041457a3511f5dedf", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/team/task.json": "20698d45484be3ec3792cf35239be1bf00610aa2b011483d8d0361142f4fd424", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/team/task.json": "9d4eb35058f515f5e23e5953c31f09da90b6bfdd63c6090aa80018b17e9c3494", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12405,13 +12409,13 @@ "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/task.toml": "2b02145eaf0d5b8cb641d409974617a1d27c167248b71551c68964f5fca34f22", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/task.toml": "6939481e04cec04a35ea4b5c53fa1e80b7c0847a10feb49fad97deca5a6518b9", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/tests/expected.json": "32fc27d4d3a42d69654dc2b2a321b6f24275012e9fef934225af53ef96bd2884", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/tests/scenario/episode.yaml": "0e851a1e9e4bb7bfc714ef546eb056576d128685a626ea50700ed76d9dbdbd5e", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/tests/scenario/notes.md": "af0afad9cd9dcd9d74e4ed418f96be8b4d49ba65f6253ffed24bc0a86e0a3f30", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/tests/scenario/record.json": "e51b9d9b56c506094e88d19895dd79b3372a7cf757852928427b8e20d0883c8d", @@ -12430,19 +12434,19 @@ "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/docker-compose.yaml": "f0be1c6955689e14c8f64823882bd327bfac6052d33ce7c9fe2085584f58e4bb", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/team/scenario/episode.yaml": "c8d24e0cc2241b16714c8cad46969825cf98670b73373a9ba6c5ac281359c567", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/team/scenario/notes.md": "14e46a9924208c5baf7fbe66202226bfdaa52aa31aaf6c2e3001a8c964dd95d3", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/team/scenario/record.json": "7f523ef21d077af793096d50ab7e6b7b97af7496c4768293423d503f93002f72", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/team/scenario/source.md": "9220fb7af7facac32fa82caae13a50a678a55cccb6087d7041457a3511f5dedf", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/team/task.json": "ddada14b7440e7318d66ba95ef0c2aefc548bf28cb39134ffc16bbde3e927403", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/team/task.json": "6f88f6b1d8cf560c6081be87c8ae3f1608819d6c6337f8e3a7c25fa54eba7a61", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12455,13 +12459,13 @@ "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/task.toml": "7498a6153c9588698f07c7bb006a685921ba1c4a685d6d0442aacae3ebc72b27", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/task.toml": "fe1c462ee545dfb1975f6d3f9a29582e03490357a4fa6443b5f0c4a12d53000a", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/tests/expected.json": "fe712a46f82d012268915d744b1a64e6835feb0dfcda0425eda2f6993b4a7fb6", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/tests/scenario/episode.yaml": "c8d24e0cc2241b16714c8cad46969825cf98670b73373a9ba6c5ac281359c567", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/tests/scenario/notes.md": "14e46a9924208c5baf7fbe66202226bfdaa52aa31aaf6c2e3001a8c964dd95d3", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/tests/scenario/record.json": "7f523ef21d077af793096d50ab7e6b7b97af7496c4768293423d503f93002f72", @@ -12480,19 +12484,19 @@ "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/docker-compose.yaml": "3ce363a4d74603845728f810ff8eeffd53390d57ea7ec3c2fe59bd6546923f89", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/team/scenario/episode.yaml": "c8d24e0cc2241b16714c8cad46969825cf98670b73373a9ba6c5ac281359c567", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/team/scenario/notes.md": "14e46a9924208c5baf7fbe66202226bfdaa52aa31aaf6c2e3001a8c964dd95d3", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/team/scenario/record.json": "7f523ef21d077af793096d50ab7e6b7b97af7496c4768293423d503f93002f72", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/team/scenario/source.md": "9220fb7af7facac32fa82caae13a50a678a55cccb6087d7041457a3511f5dedf", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/team/task.json": "63ab81054201715653e181776845a06e3dbe6902cf54de07ccd8ad1fd20ff820", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/team/task.json": "aec16c8eca41948d1610eb087e9af4ea86eb737bbbb575d67ad40dec425afbc7", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12505,13 +12509,13 @@ "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/task.toml": "b6518d9e6ab603cf6fea5299c8b59ea144f6eec2142ce857200e1c2a219c1814", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/task.toml": "2e3d0198cf3c1ce5ee3bd7cdcec503160c231991644ce8c2c6ec1183663ecbf0", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/tests/expected.json": "c2da5698af22fd25091e887ca61a26eb33b6c697d18824ffc7f2405c9da71337", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/tests/scenario/episode.yaml": "c8d24e0cc2241b16714c8cad46969825cf98670b73373a9ba6c5ac281359c567", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/tests/scenario/notes.md": "14e46a9924208c5baf7fbe66202226bfdaa52aa31aaf6c2e3001a8c964dd95d3", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/tests/scenario/record.json": "7f523ef21d077af793096d50ab7e6b7b97af7496c4768293423d503f93002f72", @@ -12530,19 +12534,19 @@ "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/docker-compose.yaml": "8a892d68fa36d8dc59217e1084348142148a04540af83aed732bb2d0384a9234", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/team/scenario/episode.yaml": "c8d24e0cc2241b16714c8cad46969825cf98670b73373a9ba6c5ac281359c567", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/team/scenario/notes.md": "14e46a9924208c5baf7fbe66202226bfdaa52aa31aaf6c2e3001a8c964dd95d3", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/team/scenario/record.json": "7f523ef21d077af793096d50ab7e6b7b97af7496c4768293423d503f93002f72", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/team/scenario/source.md": "9220fb7af7facac32fa82caae13a50a678a55cccb6087d7041457a3511f5dedf", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/team/task.json": "0a1cfa9d816f3246b8bf7fd2d465643652af99b11bf991e9c96ea2b23b631c34", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/team/task.json": "b76126a935ff2b8dbecd63aabfaf0125b7c415a45bd5d7bda1249c3ca992bba1", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12555,13 +12559,13 @@ "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/task.toml": "f92b0ae2e4a7f69b85262795842e653d879f9d47b7fe8c6ee25106ada7f7f305", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/task.toml": "bf2b90075f6a39b9bb07dc8ac8114dbe036776a92961c901e2fe4757e0ef8b48", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/tests/expected.json": "bd9eb3164d9bd9f3e8b61da8c69cd7349c538b6188b2af6c2aa8850d2e0b162f", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/tests/scenario/episode.yaml": "c8d24e0cc2241b16714c8cad46969825cf98670b73373a9ba6c5ac281359c567", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/tests/scenario/notes.md": "14e46a9924208c5baf7fbe66202226bfdaa52aa31aaf6c2e3001a8c964dd95d3", "tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/tests/scenario/record.json": "7f523ef21d077af793096d50ab7e6b7b97af7496c4768293423d503f93002f72", @@ -12580,19 +12584,19 @@ "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/docker-compose.yaml": "25b4e7a0608da7efa634dfed70ee48fddf68ba522239addafb272a792065db5e", - "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/team/scenario/episode.yaml": "644ce98dda4820e0e02f9b1f91d157b5797b46be205f39b205ed9afe16ca5be8", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/team/scenario/notes.md": "a7295c48a7fe2345693c3c5d0f7600448fd20ec06762715cb5831c77a2f3cde7", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/team/scenario/record.json": "776f3b315a64f85ba372c4c6c8b916085eaefc69e88b6f63b7e5f9b2ff2fac80", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/team/scenario/source.md": "96d3ca0418d651b5978de6ac3a7400f8e099ffa542f9aa834de0608805dc3d31", - "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/team/task.json": "db45d1c5fe73b362331ce3aa1e3c673d0924beb768209618a9f16a63f3b85a91", + "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/team/task.json": "e2d4e217296eab31a030e21ebd2b084512d98cb8f4353984b3747df4de925932", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12605,13 +12609,13 @@ "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/task.toml": "fcba331b7bd60217c4e96f88ef6dc12890ab985d60c1d43ab433f26e2e53b34a", + "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/task.toml": "aaca6623d2399860f0e34e461927e0eb5d5b7c8d409fcae78bf18b1a0cc85330", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/tests/expected.json": "1271d418f5054ddb08e325aa4aec0b3c68f3919192735fabd07f56db36d79a80", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/tests/scenario/episode.yaml": "644ce98dda4820e0e02f9b1f91d157b5797b46be205f39b205ed9afe16ca5be8", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/tests/scenario/notes.md": "a7295c48a7fe2345693c3c5d0f7600448fd20ec06762715cb5831c77a2f3cde7", "tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/tests/scenario/record.json": "776f3b315a64f85ba372c4c6c8b916085eaefc69e88b6f63b7e5f9b2ff2fac80", @@ -12630,19 +12634,19 @@ "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/docker-compose.yaml": "572f4701456dee45d6171bcc81711e0b00ef42d50740beb9c2e0944e5e38545e", - "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/team/scenario/episode.yaml": "5c50ebba912cc9a7a932133e1ace1107e5d4fd347f760eb274dc759bdc14159d", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/team/scenario/notes.md": "6aedfaa5e5662958b65370ff056098d7a4dd22c5355eaf8708683634bbc18710", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/team/scenario/record.json": "9a09720cc68f16773d7a5fd0695ec110653d95ae3def3dbfd2293043d331e54f", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/team/scenario/source.md": "96d3ca0418d651b5978de6ac3a7400f8e099ffa542f9aa834de0608805dc3d31", - "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/team/task.json": "bffc08658d28fbbec14b456f5c70ef2e0dbc180c4dfc2df82b42c145ab59f1d7", + "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/team/task.json": "fcd51ff110f6f4a99d45364d7c5520a0e33944c9f1365595703ba3c7a3274e10", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12655,13 +12659,13 @@ "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/task.toml": "4734cca3753c1c8522bf7c281b4423d32c62f8eb041d7aadb9cb3b2243b35c7b", + "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/task.toml": "983c4a15ab7d1cea28d953176787630193f76e9ffbb2ee38f7e8d9320f8a0fe9", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/tests/expected.json": "8bdb1548e4b7e958c7b597739cfda84bfba1a700980290dcbe4e99504f006069", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/tests/scenario/episode.yaml": "5c50ebba912cc9a7a932133e1ace1107e5d4fd347f760eb274dc759bdc14159d", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/tests/scenario/notes.md": "6aedfaa5e5662958b65370ff056098d7a4dd22c5355eaf8708683634bbc18710", "tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/tests/scenario/record.json": "9a09720cc68f16773d7a5fd0695ec110653d95ae3def3dbfd2293043d331e54f", @@ -12680,19 +12684,19 @@ "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/docker-compose.yaml": "0795c854bc8e32e3cd2e2c8bf08c1f6088dcbb657e2057267136dc1d0dd6b326", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/team/scenario/episode.yaml": "644ce98dda4820e0e02f9b1f91d157b5797b46be205f39b205ed9afe16ca5be8", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/team/scenario/notes.md": "a7295c48a7fe2345693c3c5d0f7600448fd20ec06762715cb5831c77a2f3cde7", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/team/scenario/record.json": "776f3b315a64f85ba372c4c6c8b916085eaefc69e88b6f63b7e5f9b2ff2fac80", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/team/scenario/source.md": "96d3ca0418d651b5978de6ac3a7400f8e099ffa542f9aa834de0608805dc3d31", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/team/task.json": "e60861e80e55d36546a4d68d7328e7f286e9d7a7f1412f28156da28b7c7c0075", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/team/task.json": "a5f7c3541bcd6bcd28550517a7681e7e37ad74191ff1e7e348921802d391d62d", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12705,13 +12709,13 @@ "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/task.toml": "d39be5490877bfc5c461e4097da24d30a165907bfa52f2e2a824994e72d4d2dc", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/task.toml": "c9b09a3add322cf8ddce68149214b02b1b40afa6fe966864cb4b3e1a9a813651", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/tests/expected.json": "28425b591c064eb6d55fcbd9117e2fadaf3f6c41d2a368944cc0f54e84c51bb6", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/tests/scenario/episode.yaml": "644ce98dda4820e0e02f9b1f91d157b5797b46be205f39b205ed9afe16ca5be8", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/tests/scenario/notes.md": "a7295c48a7fe2345693c3c5d0f7600448fd20ec06762715cb5831c77a2f3cde7", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/tests/scenario/record.json": "776f3b315a64f85ba372c4c6c8b916085eaefc69e88b6f63b7e5f9b2ff2fac80", @@ -12730,19 +12734,19 @@ "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/docker-compose.yaml": "88256a850c0e6f6c80fa1fad75db4e5e62b6fa6e4f23a93c5e638b20733fd46f", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/team/scenario/episode.yaml": "644ce98dda4820e0e02f9b1f91d157b5797b46be205f39b205ed9afe16ca5be8", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/team/scenario/notes.md": "a7295c48a7fe2345693c3c5d0f7600448fd20ec06762715cb5831c77a2f3cde7", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/team/scenario/record.json": "776f3b315a64f85ba372c4c6c8b916085eaefc69e88b6f63b7e5f9b2ff2fac80", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/team/scenario/source.md": "96d3ca0418d651b5978de6ac3a7400f8e099ffa542f9aa834de0608805dc3d31", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/team/task.json": "87a6111dafd8b51d62dbc41979f67d75b9b672efc0a12f0ef794a9ac092b7eb0", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/team/task.json": "4637304600938bc24dc190d8ea8af999aac985a95ba8589f2657507cfa8ed575", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12755,13 +12759,13 @@ "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/task.toml": "29e87112f0c4a2fb4a1414c61139a61c55d15a6166b7e6fe47dbd4136f0d24fb", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/task.toml": "fb72d3bfa1f2adbbcc2940cd6f904664cdc157d3685806782ac9f34e83b7720b", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/tests/expected.json": "43feb590b0cf23b609e3c02b11370cbe2ece13cfaa17b2150f7374d4cdeffa8e", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/tests/scenario/episode.yaml": "644ce98dda4820e0e02f9b1f91d157b5797b46be205f39b205ed9afe16ca5be8", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/tests/scenario/notes.md": "a7295c48a7fe2345693c3c5d0f7600448fd20ec06762715cb5831c77a2f3cde7", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/tests/scenario/record.json": "776f3b315a64f85ba372c4c6c8b916085eaefc69e88b6f63b7e5f9b2ff2fac80", @@ -12780,19 +12784,19 @@ "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/docker-compose.yaml": "0709c3e770f99f370af2e2fc5d9c2367ab7533c89bf77b9fb5352410f1c8b110", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/team/scenario/episode.yaml": "644ce98dda4820e0e02f9b1f91d157b5797b46be205f39b205ed9afe16ca5be8", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/team/scenario/notes.md": "a7295c48a7fe2345693c3c5d0f7600448fd20ec06762715cb5831c77a2f3cde7", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/team/scenario/record.json": "776f3b315a64f85ba372c4c6c8b916085eaefc69e88b6f63b7e5f9b2ff2fac80", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/team/scenario/source.md": "96d3ca0418d651b5978de6ac3a7400f8e099ffa542f9aa834de0608805dc3d31", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/team/task.json": "0f6ca83e5294e52877d173494a51a981419d3a6a93345d2885a062a1bb3e4731", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/team/task.json": "7ecb4ab0e660bf01fa821a08e57136bfe1a7c7741b0316a145a0c1979d12adac", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12805,13 +12809,13 @@ "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/task.toml": "95caa1ed05bea92b8967a20ccfa9a5a4d1cc04ff8f11a52c21246aab703152c5", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/task.toml": "3b068ac845272681957a3d90c42656f217c885e9bbabdf1a83896c48a77c3b87", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/tests/expected.json": "6edd41b2196365027578ed614fa7be4ffa876d5647cac248b2f4467a279a85b3", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/tests/scenario/episode.yaml": "644ce98dda4820e0e02f9b1f91d157b5797b46be205f39b205ed9afe16ca5be8", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/tests/scenario/notes.md": "a7295c48a7fe2345693c3c5d0f7600448fd20ec06762715cb5831c77a2f3cde7", "tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/tests/scenario/record.json": "776f3b315a64f85ba372c4c6c8b916085eaefc69e88b6f63b7e5f9b2ff2fac80", @@ -12830,19 +12834,19 @@ "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/docker-compose.yaml": "7566bbd1bdb1aeeeb1f04ea9a10dbe67a9ea7b7521a42fcf0ae0d6251c317e4c", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/team/scenario/episode.yaml": "d4a35f1aca5051593617d91e01d9d54082201200e39003f5ee43bb454603f4f4", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/team/scenario/notes.md": "05b8849e2f8f74ef1aba48dc36dce583b0149ced0b9dc8dc3d6ae3cb884e25e1", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/team/scenario/record.json": "6095f7ceb4a293840a84c4d07e06c66a438f8063daaddc8860369da46331e53e", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/team/scenario/source.md": "c47c0f952dd4220573341be53d5a58ce2efdc75199d45c254f7fa016e94d30ed", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/team/task.json": "c9373823bdc6b6b401d4c233869b85469ada77271a8dd236d219c0a387e22578", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/team/task.json": "b14daaaa4d9f4be5496843fa9baeaa1c02cf5e1b41b3239ce45af7fc3a6eff98", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12855,13 +12859,13 @@ "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/task.toml": "a06f5680ceb07593f29e982bf382878fa47622d0937e0e082d61d534ad91ef61", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/task.toml": "8616dcea7837e3f3eb8014cc6a464828ba70ce34b2f405871d8a4309498879ec", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/tests/expected.json": "dc869cb744902b435f488755fe3d3e731225ec82c9749e72faf1ceefac566755", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/tests/scenario/episode.yaml": "d4a35f1aca5051593617d91e01d9d54082201200e39003f5ee43bb454603f4f4", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/tests/scenario/notes.md": "05b8849e2f8f74ef1aba48dc36dce583b0149ced0b9dc8dc3d6ae3cb884e25e1", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/tests/scenario/record.json": "6095f7ceb4a293840a84c4d07e06c66a438f8063daaddc8860369da46331e53e", @@ -12880,19 +12884,19 @@ "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/docker-compose.yaml": "cafa2af4f8aa86b2d3ed69e926ebc9a4b5e56a740c0cb79cdcdb90a91673edee", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/team/scenario/episode.yaml": "d4a35f1aca5051593617d91e01d9d54082201200e39003f5ee43bb454603f4f4", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/team/scenario/notes.md": "05b8849e2f8f74ef1aba48dc36dce583b0149ced0b9dc8dc3d6ae3cb884e25e1", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/team/scenario/record.json": "6095f7ceb4a293840a84c4d07e06c66a438f8063daaddc8860369da46331e53e", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/team/scenario/source.md": "c47c0f952dd4220573341be53d5a58ce2efdc75199d45c254f7fa016e94d30ed", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/team/task.json": "5154a87087eb6e5b720138d2e56130e5c4a7e32f63f685b8aa2b86fdac6fb8a3", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/team/task.json": "b8428231d46b208adf24e20286f9013b2c5c5aaa938cb05a677459dd2fa9bcdb", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12905,13 +12909,13 @@ "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/task.toml": "97c7c918fbdab4a0976ce0ea86f2c07494beca2faaccd3974ae2aaeb2ee84676", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/task.toml": "346bba1fc8b37bb30bdbacc0b70c2a3526d99628cfad63258d35d68dd8ec9558", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/tests/expected.json": "6c192e256c587646ca7ae175698790ff24bc3dae8ebc4e64180bdc5deea091e7", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/tests/scenario/episode.yaml": "d4a35f1aca5051593617d91e01d9d54082201200e39003f5ee43bb454603f4f4", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/tests/scenario/notes.md": "05b8849e2f8f74ef1aba48dc36dce583b0149ced0b9dc8dc3d6ae3cb884e25e1", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/tests/scenario/record.json": "6095f7ceb4a293840a84c4d07e06c66a438f8063daaddc8860369da46331e53e", @@ -12930,20 +12934,20 @@ "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/docker-compose.yaml": "ec1dcbbd9bb34c599fad3817b8e3f02a0c35913ae4bcb3ee88d954c25de4f5af", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/team/scenario/episode.yaml": "58c2eeebf2575e1ebb80296de55bef125db764f321af33c92b13a3ca0b5c0f3d", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/team/scenario/notes.md": "05b8849e2f8f74ef1aba48dc36dce583b0149ced0b9dc8dc3d6ae3cb884e25e1", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/team/scenario/prefill.json": "67d75fb977dbbdf8b7a26a1a65f6a02638f0e4ee9a8a5cdc6e8826871987b640", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/team/scenario/record.json": "6095f7ceb4a293840a84c4d07e06c66a438f8063daaddc8860369da46331e53e", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/team/scenario/source.md": "c47c0f952dd4220573341be53d5a58ce2efdc75199d45c254f7fa016e94d30ed", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/team/task.json": "c8de1b13970b66b70966e0c4d3ed0a8cc00471e002ea61a94ed12e1ff7428527", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/team/task.json": "7a77a80d51fab90669b59421fb522aae52d9b84ee58c844df6a5550b9ce07304", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -12956,13 +12960,13 @@ "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/task.toml": "ebea5fb128702963a2ced24e92000cf215133fbfa4a4a47e5413e19e51733a70", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/task.toml": "d3c9a244766c023cc9eeb16511874f9e9236893c13eda261766e491b9f0852c7", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/tests/expected.json": "e41b39e5aa031c4b4d693db936e894b9c415ef1530144285a23eca95e39689ce", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/tests/scenario/episode.yaml": "58c2eeebf2575e1ebb80296de55bef125db764f321af33c92b13a3ca0b5c0f3d", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/tests/scenario/notes.md": "05b8849e2f8f74ef1aba48dc36dce583b0149ced0b9dc8dc3d6ae3cb884e25e1", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/tests/scenario/prefill.json": "67d75fb977dbbdf8b7a26a1a65f6a02638f0e4ee9a8a5cdc6e8826871987b640", @@ -12982,20 +12986,20 @@ "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/docker-compose.yaml": "c38afcefe642c3d687bd2b81919c3282df200e91bd90c1a2d02bd1163fbd1e2a", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/team/scenario/episode.yaml": "58c2eeebf2575e1ebb80296de55bef125db764f321af33c92b13a3ca0b5c0f3d", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/team/scenario/notes.md": "05b8849e2f8f74ef1aba48dc36dce583b0149ced0b9dc8dc3d6ae3cb884e25e1", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/team/scenario/prefill.json": "67d75fb977dbbdf8b7a26a1a65f6a02638f0e4ee9a8a5cdc6e8826871987b640", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/team/scenario/record.json": "6095f7ceb4a293840a84c4d07e06c66a438f8063daaddc8860369da46331e53e", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/team/scenario/source.md": "c47c0f952dd4220573341be53d5a58ce2efdc75199d45c254f7fa016e94d30ed", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/team/task.json": "cbd56fde0e8f23551cdd648c873e55fbd98a4e79ed9f249e9f9d5bbb69fb7f7d", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/team/task.json": "2484ab577f309f20f6360da6f8fc2a632d425639ecf56f89765923903d6f6b5e", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13008,13 +13012,13 @@ "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/task.toml": "678fdaa2022f4045be2812a2f2bca6a316f106239a4b831ec9b951ff542a15e4", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/task.toml": "5047eb80cf06221d010f5df9f99aaaef01e7194a6593062f2ccd334977a7617f", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/tests/expected.json": "bcdb69a3a771cfd773773976b574a62c72b2f4cd1321aa21ef450af10326c70a", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/tests/scenario/episode.yaml": "58c2eeebf2575e1ebb80296de55bef125db764f321af33c92b13a3ca0b5c0f3d", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/tests/scenario/notes.md": "05b8849e2f8f74ef1aba48dc36dce583b0149ced0b9dc8dc3d6ae3cb884e25e1", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/tests/scenario/prefill.json": "67d75fb977dbbdf8b7a26a1a65f6a02638f0e4ee9a8a5cdc6e8826871987b640", @@ -13034,20 +13038,20 @@ "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/docker-compose.yaml": "4a3d11727fe22c8271c4bc6d9a15149713f9c7645f8a9412c9f54236464d3a4f", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/team/scenario/episode.yaml": "58c2eeebf2575e1ebb80296de55bef125db764f321af33c92b13a3ca0b5c0f3d", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/team/scenario/notes.md": "05b8849e2f8f74ef1aba48dc36dce583b0149ced0b9dc8dc3d6ae3cb884e25e1", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/team/scenario/prefill.json": "67d75fb977dbbdf8b7a26a1a65f6a02638f0e4ee9a8a5cdc6e8826871987b640", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/team/scenario/record.json": "6095f7ceb4a293840a84c4d07e06c66a438f8063daaddc8860369da46331e53e", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/team/scenario/source.md": "c47c0f952dd4220573341be53d5a58ce2efdc75199d45c254f7fa016e94d30ed", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/team/task.json": "c0f86a43ab96927b6c13bebdd624bdd6ca2d2f1946f9054aed470d1aa01a2b22", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/team/task.json": "81f59ecd0fc3023d1dd5c28d7abecdb16120023e4c9a1e36f53573eca9fd0784", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13060,13 +13064,13 @@ "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/task.toml": "89a40fc2ae68eefd843235d1e8189d5b27e452cb75b0e2cdc5558899721fa689", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/task.toml": "8bb281219df6ab594731487b69a7ca43d6d0a52d088e16cceeb249477d3484b6", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/tests/expected.json": "121cbae9b8e28c25465e1735ea9a19fac5b263cadc06beff4de4d223e544b51c", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/tests/scenario/episode.yaml": "58c2eeebf2575e1ebb80296de55bef125db764f321af33c92b13a3ca0b5c0f3d", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/tests/scenario/notes.md": "05b8849e2f8f74ef1aba48dc36dce583b0149ced0b9dc8dc3d6ae3cb884e25e1", "tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/tests/scenario/prefill.json": "67d75fb977dbbdf8b7a26a1a65f6a02638f0e4ee9a8a5cdc6e8826871987b640", @@ -13086,19 +13090,19 @@ "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/docker-compose.yaml": "d2a70495cdc8717b5cc29af6a7140d551c77a417fe5fc5d1c84e095af04dc448", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/team/scenario/episode.yaml": "155f7b5d325c773009ff430bcd20388ded40ac61de4642f63cc970e194cdf135", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/team/scenario/notes.md": "d5cfef8d593a19cbbd23641f5003f203d407793d7def5d03a181ed39184b1a95", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/team/scenario/record.json": "252ff940e5dec8500b2d43f0ed2992570228f12d05d655ec580b08a3d8351251", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/team/scenario/source.md": "f5105c6a88150566b1b41c12a012721f4d79ae2efcf51724b0479020d58e4b18", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/team/task.json": "b3a8a4a81f99565fc4e3fc28faae0b572fe3aea58c430646abc57d836ff06ce9", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/team/task.json": "096a3764ebb9b7bad2a9e73be7c794408b200c2ceee457c83f7ed3b20fb25c80", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13111,13 +13115,13 @@ "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/task.toml": "9125799a3c37471beb847c34fc6cb69012cea0e6df6336534fc9cecabb1cb19e", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/task.toml": "12043259ba8e925e43461435540bc63c2087b4d91ff6058708df844a2b1bc918", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/tests/expected.json": "35bb4b0c94f50dcf1d04493bd37396dcc8501f5ad5ae3ce9890b21c3212f0efd", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/tests/scenario/episode.yaml": "155f7b5d325c773009ff430bcd20388ded40ac61de4642f63cc970e194cdf135", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/tests/scenario/notes.md": "d5cfef8d593a19cbbd23641f5003f203d407793d7def5d03a181ed39184b1a95", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/tests/scenario/record.json": "252ff940e5dec8500b2d43f0ed2992570228f12d05d655ec580b08a3d8351251", @@ -13136,19 +13140,19 @@ "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/docker-compose.yaml": "8008a54b076177a7f86b2cd69a123d903a0ddce0b65710182b6681c39c125dec", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/team/scenario/episode.yaml": "155f7b5d325c773009ff430bcd20388ded40ac61de4642f63cc970e194cdf135", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/team/scenario/notes.md": "d5cfef8d593a19cbbd23641f5003f203d407793d7def5d03a181ed39184b1a95", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/team/scenario/record.json": "252ff940e5dec8500b2d43f0ed2992570228f12d05d655ec580b08a3d8351251", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/team/scenario/source.md": "f5105c6a88150566b1b41c12a012721f4d79ae2efcf51724b0479020d58e4b18", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/team/task.json": "3fcb64d3df8b20e901d82690cb0c11fd2547b54deaad66228a4f8303016bd004", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/team/task.json": "0e84c5bdf37f8f60ab9733e34b1ab9d66410e5f22a083aa8c4f3348f8877b9a0", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13161,13 +13165,13 @@ "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/task.toml": "eb282c231b52c78fb7291ff81601f324c61f3bdd3b3d896c6b16cfa89519874c", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/task.toml": "1ab4538ac73d58aab49f114295e1f62d18e65f3843a2fef693130df7e04bbfdd", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/tests/expected.json": "24f5614b791b28cab1bd4380d8d20a3cdb4e6dc792ef9dbd96a917be64dabaa5", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/tests/scenario/episode.yaml": "155f7b5d325c773009ff430bcd20388ded40ac61de4642f63cc970e194cdf135", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/tests/scenario/notes.md": "d5cfef8d593a19cbbd23641f5003f203d407793d7def5d03a181ed39184b1a95", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/tests/scenario/record.json": "252ff940e5dec8500b2d43f0ed2992570228f12d05d655ec580b08a3d8351251", @@ -13186,20 +13190,20 @@ "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/docker-compose.yaml": "e3747fbb51b04c7c5571bb3098572a61c18237ccf35467accd60582d2836739a", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/team/scenario/episode.yaml": "b86a1982b7897c727e4a4f575bf80e94602606d02fd5a90d9eddc9802ede0e80", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/team/scenario/notes.md": "d5cfef8d593a19cbbd23641f5003f203d407793d7def5d03a181ed39184b1a95", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/team/scenario/prefill.json": "f9a17efd1e32a206dedd962bdf71f2a46cd31e56954dd2f827ba34a72468de50", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/team/scenario/record.json": "252ff940e5dec8500b2d43f0ed2992570228f12d05d655ec580b08a3d8351251", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/team/scenario/source.md": "f5105c6a88150566b1b41c12a012721f4d79ae2efcf51724b0479020d58e4b18", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/team/task.json": "5832e52bc7265ef4e1bc4f895e747d5ed024cbbbdced4ed40df3d77cd2f82f64", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/team/task.json": "e2940dbc3d4f02146b4b7ff9cad44d62fc1a6e6c44032fb4f35a32748ba59dc7", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13212,13 +13216,13 @@ "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/task.toml": "91efb32ea45e6f73988d4d104c325527a57b66ad365e69d9043684efdc0c6ea6", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/task.toml": "6d6f79012aaddef2a303845cb86b330e4e9f5289a53767972d338da84a2b8a98", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/tests/expected.json": "79b3a869a95b50337160c95c654d617467abd02b223146fd31fa35754bf8c0af", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/tests/scenario/episode.yaml": "b86a1982b7897c727e4a4f575bf80e94602606d02fd5a90d9eddc9802ede0e80", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/tests/scenario/notes.md": "d5cfef8d593a19cbbd23641f5003f203d407793d7def5d03a181ed39184b1a95", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/tests/scenario/prefill.json": "f9a17efd1e32a206dedd962bdf71f2a46cd31e56954dd2f827ba34a72468de50", @@ -13238,20 +13242,20 @@ "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/docker-compose.yaml": "a3e58da20df9e9166ed9729f080f105c1400531aecb910a4165f7cb91970b5a2", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/team/scenario/episode.yaml": "b86a1982b7897c727e4a4f575bf80e94602606d02fd5a90d9eddc9802ede0e80", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/team/scenario/notes.md": "d5cfef8d593a19cbbd23641f5003f203d407793d7def5d03a181ed39184b1a95", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/team/scenario/prefill.json": "f9a17efd1e32a206dedd962bdf71f2a46cd31e56954dd2f827ba34a72468de50", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/team/scenario/record.json": "252ff940e5dec8500b2d43f0ed2992570228f12d05d655ec580b08a3d8351251", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/team/scenario/source.md": "f5105c6a88150566b1b41c12a012721f4d79ae2efcf51724b0479020d58e4b18", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/team/task.json": "ee1dc9468b2e5926b2cf4ff49a016138ed6abad1f5bad7427ef2daaf2b41efd7", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/team/task.json": "1b04ce0279c1c5b270ae4a566bdca16950fbfa0ce786552f1af7f05115571125", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13264,13 +13268,13 @@ "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/task.toml": "8e3cf937f92c382a9528443ad6f9a39c672e0bef130d61322b44942761b2bb32", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/task.toml": "653ba21bd71be5cb5e7ba2c0989860283c246c883ad8d0a6754769c9053c76e3", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/tests/expected.json": "320582b3dfd3c8f9c4406a509066897a8d790d8332a0c24e936dc754b3f82589", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/tests/scenario/episode.yaml": "b86a1982b7897c727e4a4f575bf80e94602606d02fd5a90d9eddc9802ede0e80", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/tests/scenario/notes.md": "d5cfef8d593a19cbbd23641f5003f203d407793d7def5d03a181ed39184b1a95", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/tests/scenario/prefill.json": "f9a17efd1e32a206dedd962bdf71f2a46cd31e56954dd2f827ba34a72468de50", @@ -13290,20 +13294,20 @@ "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/docker-compose.yaml": "f9e42e20d96eb0077342e3a8533bc05cbe93617a6e989f995c682f68992f9314", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/team/scenario/episode.yaml": "b86a1982b7897c727e4a4f575bf80e94602606d02fd5a90d9eddc9802ede0e80", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/team/scenario/notes.md": "d5cfef8d593a19cbbd23641f5003f203d407793d7def5d03a181ed39184b1a95", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/team/scenario/prefill.json": "f9a17efd1e32a206dedd962bdf71f2a46cd31e56954dd2f827ba34a72468de50", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/team/scenario/record.json": "252ff940e5dec8500b2d43f0ed2992570228f12d05d655ec580b08a3d8351251", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/team/scenario/source.md": "f5105c6a88150566b1b41c12a012721f4d79ae2efcf51724b0479020d58e4b18", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/team/task.json": "c9a1d5146d5fcfb785e10cac90ad8f0087d03264d5a35e11381e0860cfcf9a5e", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/team/task.json": "63a8846f222d3f32e10efa59c53230c1dd56a74dc2a35f526b5d4fb5a4dbec7d", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13316,13 +13320,13 @@ "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/task.toml": "5b785a145e453992cacec288be550bac0adb76f9f8c8fc4687de3dbe00ca5044", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/task.toml": "abacb232d446fbf8e8f7d6731329c7da712f9a476b0c731a8e411ee0af24d12a", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/tests/expected.json": "5e2a1ec3b7f73fc9254e8f081837de089f0aa0b8b00d6cf996896a38b4ee3a1a", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/tests/scenario/episode.yaml": "b86a1982b7897c727e4a4f575bf80e94602606d02fd5a90d9eddc9802ede0e80", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/tests/scenario/notes.md": "d5cfef8d593a19cbbd23641f5003f203d407793d7def5d03a181ed39184b1a95", "tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/tests/scenario/prefill.json": "f9a17efd1e32a206dedd962bdf71f2a46cd31e56954dd2f827ba34a72468de50", @@ -13342,19 +13346,19 @@ "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/docker-compose.yaml": "7601af94a4fd416c0824c362352eaad2697aa208f14b0bea4e2b1177b6d66550", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/team/scenario/episode.yaml": "d3beea4da98c1f53b0740f11df8b777ce832bcb64e6451ae67701ad9fd7a9549", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/team/scenario/notes.md": "a4e2a36b891bae61927eec0c60068a59b8963c4bf4b271c814786f7b43af4e79", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/team/scenario/record.json": "971bea553f33358d0a6ae554ca380d8c8a809e1987b7771fafcbf6ca045bab18", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/team/scenario/source.md": "caf56ee1dece0ad8fceaa18520f01dd4bea56fcd4ba029416fb2a1507183553f", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/team/task.json": "8c6b57bee5aa519ac155c4ec33deeaf9c6cf6e92c37f38eff7051775d5212746", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/team/task.json": "fce978a46756ceac93055dd53ffc49a4e5c383d40d34712c8353b43bf5d4676f", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13367,13 +13371,13 @@ "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/task.toml": "4ec907285d7df6d61ad0c5bec12b50ef3ed2e67738afc870af0c200f68088ff0", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/task.toml": "06d0a93fa7df7adc33bfd54c168f2c24f3f15251515b4f90f7819200c828c4cf", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/tests/expected.json": "4a379bc9f6d0dccb04ce1722f193fcff6efc1ca18d5621f5a2e03e57c8235dcb", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/tests/scenario/episode.yaml": "d3beea4da98c1f53b0740f11df8b777ce832bcb64e6451ae67701ad9fd7a9549", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/tests/scenario/notes.md": "a4e2a36b891bae61927eec0c60068a59b8963c4bf4b271c814786f7b43af4e79", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/tests/scenario/record.json": "971bea553f33358d0a6ae554ca380d8c8a809e1987b7771fafcbf6ca045bab18", @@ -13392,19 +13396,19 @@ "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/docker-compose.yaml": "442b394d9a6cfe9fbefe5e2eaae478cdacb7babda54885e99068ba986de204ee", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/team/scenario/episode.yaml": "d3beea4da98c1f53b0740f11df8b777ce832bcb64e6451ae67701ad9fd7a9549", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/team/scenario/notes.md": "a4e2a36b891bae61927eec0c60068a59b8963c4bf4b271c814786f7b43af4e79", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/team/scenario/record.json": "971bea553f33358d0a6ae554ca380d8c8a809e1987b7771fafcbf6ca045bab18", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/team/scenario/source.md": "caf56ee1dece0ad8fceaa18520f01dd4bea56fcd4ba029416fb2a1507183553f", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/team/task.json": "3e23636595f707a984fb875e525f8b9a059631d0c600c40e6c0227e5ccf3346e", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/team/task.json": "e225eb9fa2312f4f10af81ef74054876817ac6d8eb1cdfa651d0908da65a93af", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13417,13 +13421,13 @@ "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/task.toml": "7478329f59a3bbb06b1fa39a3a77e1d44007c3fef3f73c647c72a4800df9cdd8", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/task.toml": "02ca9618fd7b739f76c53360d9d59d013b63e04ca897e2e80ef13d5395d25cc3", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/tests/expected.json": "67a05b82bb838c3c8b9449beeb01b27ce958aa99605f1059db155ff340241de2", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/tests/scenario/episode.yaml": "d3beea4da98c1f53b0740f11df8b777ce832bcb64e6451ae67701ad9fd7a9549", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/tests/scenario/notes.md": "a4e2a36b891bae61927eec0c60068a59b8963c4bf4b271c814786f7b43af4e79", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/tests/scenario/record.json": "971bea553f33358d0a6ae554ca380d8c8a809e1987b7771fafcbf6ca045bab18", @@ -13442,20 +13446,20 @@ "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/docker-compose.yaml": "6999f5ee33c45b20482539375dc7a20538f31bce1c2fde7b3bd275ff0a153136", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/team/scenario/episode.yaml": "06c11f898f82459eaca5b158f4f8d3ce7388814e8b7386a271bd4a9a472af01f", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/team/scenario/notes.md": "a4e2a36b891bae61927eec0c60068a59b8963c4bf4b271c814786f7b43af4e79", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/team/scenario/prefill.json": "6712e32fb7c27f4e73a932df94b57af4d8964e5f5d466a3e53f7195728d52919", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/team/scenario/record.json": "971bea553f33358d0a6ae554ca380d8c8a809e1987b7771fafcbf6ca045bab18", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/team/scenario/source.md": "caf56ee1dece0ad8fceaa18520f01dd4bea56fcd4ba029416fb2a1507183553f", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/team/task.json": "2cefb3a73399d934c6691a1c6eb9cc2c63c5cfaffebd1fff4b9aeb78b222686c", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/team/task.json": "75df3e6674e0b9ebede238ce5b450f15c5cd5f354c0071eeb8587d8e173d86f9", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13468,13 +13472,13 @@ "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/task.toml": "e44efa90307e7909fee2568abb4f5299040980a88706340c6d2cf71700d519e8", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/task.toml": "c338f232875c893212223efdc477224c68c329c583fed10851112e5138a7959d", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/tests/expected.json": "90ff2061469bf73b838e6501453bdf0c8a277e85b0710d2244d09c6e250b80a2", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/tests/scenario/episode.yaml": "06c11f898f82459eaca5b158f4f8d3ce7388814e8b7386a271bd4a9a472af01f", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/tests/scenario/notes.md": "a4e2a36b891bae61927eec0c60068a59b8963c4bf4b271c814786f7b43af4e79", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/tests/scenario/prefill.json": "6712e32fb7c27f4e73a932df94b57af4d8964e5f5d466a3e53f7195728d52919", @@ -13494,20 +13498,20 @@ "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/docker-compose.yaml": "e4dc6ca90b3b608a4d54b675f918057d524af5a1345e5cd09a76aa0e3f98b1a0", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/team/scenario/episode.yaml": "06c11f898f82459eaca5b158f4f8d3ce7388814e8b7386a271bd4a9a472af01f", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/team/scenario/notes.md": "a4e2a36b891bae61927eec0c60068a59b8963c4bf4b271c814786f7b43af4e79", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/team/scenario/prefill.json": "6712e32fb7c27f4e73a932df94b57af4d8964e5f5d466a3e53f7195728d52919", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/team/scenario/record.json": "971bea553f33358d0a6ae554ca380d8c8a809e1987b7771fafcbf6ca045bab18", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/team/scenario/source.md": "caf56ee1dece0ad8fceaa18520f01dd4bea56fcd4ba029416fb2a1507183553f", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/team/task.json": "510d2d32adf5eefb32161f64389e1c148f4a5a20e4d31b92297b0834ae3722d4", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/team/task.json": "3d8fc3a7b87ff70711b616981ded9f8d2599246e70d598ce2564a57a1314e9f8", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13520,13 +13524,13 @@ "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/task.toml": "e73e62115bdb1edb126b2d9cd00c93e2419da4ee0cc4d3cfab61e4a6d7f527db", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/task.toml": "e65323e4ef60b82a0f78aa9e906b33b4ed480a788dfaf9707648227ab5e941da", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/tests/expected.json": "29c124ba88a30976056b00998cdc463f470b8e581c7f0cee521dc4c0e63b3ef0", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/tests/scenario/episode.yaml": "06c11f898f82459eaca5b158f4f8d3ce7388814e8b7386a271bd4a9a472af01f", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/tests/scenario/notes.md": "a4e2a36b891bae61927eec0c60068a59b8963c4bf4b271c814786f7b43af4e79", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/tests/scenario/prefill.json": "6712e32fb7c27f4e73a932df94b57af4d8964e5f5d466a3e53f7195728d52919", @@ -13546,20 +13550,20 @@ "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/docker-compose.yaml": "b4d95ebf25d94c7279c5a74ed468babbb7dcc2de0151f08e0cbb48f561426ae9", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/team/scenario/episode.yaml": "06c11f898f82459eaca5b158f4f8d3ce7388814e8b7386a271bd4a9a472af01f", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/team/scenario/notes.md": "a4e2a36b891bae61927eec0c60068a59b8963c4bf4b271c814786f7b43af4e79", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/team/scenario/prefill.json": "6712e32fb7c27f4e73a932df94b57af4d8964e5f5d466a3e53f7195728d52919", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/team/scenario/record.json": "971bea553f33358d0a6ae554ca380d8c8a809e1987b7771fafcbf6ca045bab18", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/team/scenario/source.md": "caf56ee1dece0ad8fceaa18520f01dd4bea56fcd4ba029416fb2a1507183553f", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/team/task.json": "7d662b3ec8557c9591f33e3ecc8fda2ecacf58818a46c16db662331a5aa1a203", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/team/task.json": "6b930afad30c2c2eef3a081a882eed116791970181731469235d0809fd968556", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13572,13 +13576,13 @@ "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/task.toml": "c3d241d2258317b37316cace4007dd1401a056b44cf7edcdde0cfb0e6b0df6e9", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/task.toml": "56282bc946c997bebe7afde5c42f727856236d76774208833645b90c7ba1ad7d", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/tests/expected.json": "402633a74c3105073553b4aaac1cbdb13a8f46043bd6203be814686c06f6ae8c", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/tests/scenario/episode.yaml": "06c11f898f82459eaca5b158f4f8d3ce7388814e8b7386a271bd4a9a472af01f", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/tests/scenario/notes.md": "a4e2a36b891bae61927eec0c60068a59b8963c4bf4b271c814786f7b43af4e79", "tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/tests/scenario/prefill.json": "6712e32fb7c27f4e73a932df94b57af4d8964e5f5d466a3e53f7195728d52919", @@ -13598,19 +13602,19 @@ "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/docker-compose.yaml": "9584960f45f91965e0ca45d75e52be1df74b5f4b5c781a35d611ba74bee426fe", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/team/scenario/episode.yaml": "71c78c39743b2a1c034047f0702b98ea9b071fb2dbd07942b0972dfec01ce604", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/team/scenario/notes.md": "cec6b3c2fdeb2ba7c13c6cc28959bfd4c15db5b432f23f2a82c369ceb83755ed", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/team/scenario/record.json": "a132f8e618997f5e2921665fa5515c1b2b8bfbf2a63d249ea7a3d187017e1a7e", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/team/scenario/source.md": "8b632fd9d695b11f0d17410519dd6849e7a7f75661dd44f89575062d72994a5b", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/team/task.json": "8b337f4188d6f4cb92c2e28ab1bd701d443ed049bde458a595e74cd178971f73", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/team/task.json": "7e61b65397500b8611867216621b8415b3a3f573b5cb75046a64606848ce6dd2", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13623,13 +13627,13 @@ "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/task.toml": "254d0e5915c71b1ef00a7da731f6e75fd62512b2d10620d6c046bad146436aec", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/task.toml": "d6f2223f82bd295905b58018c53386c4fc241b23fd025856f25e24474a107f0d", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/tests/expected.json": "60bd1020877da269733d424146b3e56edbbaf184fdee68fee5d296ee4f67cf11", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/tests/scenario/episode.yaml": "71c78c39743b2a1c034047f0702b98ea9b071fb2dbd07942b0972dfec01ce604", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/tests/scenario/notes.md": "cec6b3c2fdeb2ba7c13c6cc28959bfd4c15db5b432f23f2a82c369ceb83755ed", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/tests/scenario/record.json": "a132f8e618997f5e2921665fa5515c1b2b8bfbf2a63d249ea7a3d187017e1a7e", @@ -13648,19 +13652,19 @@ "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/docker-compose.yaml": "0ff6ac6bb96307c95fca827306b74956561118814402ac52cfc79be1ec4fb8e7", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/team/scenario/episode.yaml": "71c78c39743b2a1c034047f0702b98ea9b071fb2dbd07942b0972dfec01ce604", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/team/scenario/notes.md": "cec6b3c2fdeb2ba7c13c6cc28959bfd4c15db5b432f23f2a82c369ceb83755ed", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/team/scenario/record.json": "a132f8e618997f5e2921665fa5515c1b2b8bfbf2a63d249ea7a3d187017e1a7e", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/team/scenario/source.md": "8b632fd9d695b11f0d17410519dd6849e7a7f75661dd44f89575062d72994a5b", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/team/task.json": "5d20326fafb0fdc9028360504823093731675eee6449cab4cfb122acb647120c", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/team/task.json": "058aa16c469322814ef692467c0cc17c03f1a20dd97f22b753af5988ae0ccc6b", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13673,13 +13677,13 @@ "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/task.toml": "029856c83c7a2bdea61443dac49a3be5ca13758833ecb37bf6d96aee9a55c836", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/task.toml": "9e7448560f720cc5031561372cc1706868f16dbd5458f98ae3dba353acbc63fa", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/tests/expected.json": "98ad50b32150bc54feb31d90c2f34fcbe9384f2353743ab99b6853fd8a621c9d", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/tests/scenario/episode.yaml": "71c78c39743b2a1c034047f0702b98ea9b071fb2dbd07942b0972dfec01ce604", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/tests/scenario/notes.md": "cec6b3c2fdeb2ba7c13c6cc28959bfd4c15db5b432f23f2a82c369ceb83755ed", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/tests/scenario/record.json": "a132f8e618997f5e2921665fa5515c1b2b8bfbf2a63d249ea7a3d187017e1a7e", @@ -13698,20 +13702,20 @@ "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/docker-compose.yaml": "8d73f3e9bc838cac1a983b0e8044c288a79e252460dceecadd5b8c39a16cc719", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/team/scenario/episode.yaml": "78d72b57c40858e564c73ee1d03161b130ffeea73ba5cbfea7ef80eea31c683a", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/team/scenario/notes.md": "cec6b3c2fdeb2ba7c13c6cc28959bfd4c15db5b432f23f2a82c369ceb83755ed", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/team/scenario/prefill.json": "787a6b69669d22febd1cdc17c7e5e50b7bdf78fb6e4dae7d461d2fe8a75f1de7", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/team/scenario/record.json": "a132f8e618997f5e2921665fa5515c1b2b8bfbf2a63d249ea7a3d187017e1a7e", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/team/scenario/source.md": "8b632fd9d695b11f0d17410519dd6849e7a7f75661dd44f89575062d72994a5b", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/team/task.json": "ba45d3b2aaf066b9b850ee532d5c88d2f981804630a54a31a94ed21e527bb29d", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/team/task.json": "dc82349d687f364a0d8bdacd102d562736361d64ca826dc659fa0d552a8210ed", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13724,13 +13728,13 @@ "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/task.toml": "a83686ecd0149bd3fc59485316e67e536740108c7139239b38491bd843a41a87", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/task.toml": "7c1d47680393a84e194b098fbbb6ba2c2a58c58368caa099aef697da35f006bb", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/tests/expected.json": "27347ef55fe6dc06b4391b693008330bc81fde62e7e9d54a8787584e90972986", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/tests/scenario/episode.yaml": "78d72b57c40858e564c73ee1d03161b130ffeea73ba5cbfea7ef80eea31c683a", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/tests/scenario/notes.md": "cec6b3c2fdeb2ba7c13c6cc28959bfd4c15db5b432f23f2a82c369ceb83755ed", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/tests/scenario/prefill.json": "787a6b69669d22febd1cdc17c7e5e50b7bdf78fb6e4dae7d461d2fe8a75f1de7", @@ -13750,20 +13754,20 @@ "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/docker-compose.yaml": "09e3d1e7d47e706750d9ab1f8f8b04fe0ee5438a53cfb5fb0ce5c2fe218e90fc", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/team/scenario/episode.yaml": "78d72b57c40858e564c73ee1d03161b130ffeea73ba5cbfea7ef80eea31c683a", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/team/scenario/notes.md": "cec6b3c2fdeb2ba7c13c6cc28959bfd4c15db5b432f23f2a82c369ceb83755ed", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/team/scenario/prefill.json": "787a6b69669d22febd1cdc17c7e5e50b7bdf78fb6e4dae7d461d2fe8a75f1de7", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/team/scenario/record.json": "a132f8e618997f5e2921665fa5515c1b2b8bfbf2a63d249ea7a3d187017e1a7e", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/team/scenario/source.md": "8b632fd9d695b11f0d17410519dd6849e7a7f75661dd44f89575062d72994a5b", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/team/task.json": "da7f0c8cdf5599f29d35c9d568f7163e759d6e92aee10d07dd075c79d4e02967", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/team/task.json": "b895467f9915e326411e80371c2f5f5450fa2553ee7b6e8561ca3dcda55af34a", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13776,13 +13780,13 @@ "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/task.toml": "7637bce2aecff2d649320b68b5170f53fd16e5d92bcc1474da77f7798d2770b1", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/task.toml": "fad3812fceffb7428f6f9fcfd7d08cee22de35496e7002ea9e412ec51d0fddb2", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/tests/expected.json": "18ad80c2f7b9819627b8c04eda365b343082eaa194b387cbb6f0d32151a03c52", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/tests/scenario/episode.yaml": "78d72b57c40858e564c73ee1d03161b130ffeea73ba5cbfea7ef80eea31c683a", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/tests/scenario/notes.md": "cec6b3c2fdeb2ba7c13c6cc28959bfd4c15db5b432f23f2a82c369ceb83755ed", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/tests/scenario/prefill.json": "787a6b69669d22febd1cdc17c7e5e50b7bdf78fb6e4dae7d461d2fe8a75f1de7", @@ -13802,20 +13806,20 @@ "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/docker-compose.yaml": "6e1ebd60ee87c528db38f23854b226b94cbd58b75ab43fa8e8606926c39d2a2f", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/team/scenario/episode.yaml": "78d72b57c40858e564c73ee1d03161b130ffeea73ba5cbfea7ef80eea31c683a", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/team/scenario/notes.md": "cec6b3c2fdeb2ba7c13c6cc28959bfd4c15db5b432f23f2a82c369ceb83755ed", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/team/scenario/prefill.json": "787a6b69669d22febd1cdc17c7e5e50b7bdf78fb6e4dae7d461d2fe8a75f1de7", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/team/scenario/record.json": "a132f8e618997f5e2921665fa5515c1b2b8bfbf2a63d249ea7a3d187017e1a7e", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/team/scenario/source.md": "8b632fd9d695b11f0d17410519dd6849e7a7f75661dd44f89575062d72994a5b", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/team/task.json": "fe5e2c019025d69b999271befb1043bde22c93fcf4898332c4af63d3ebd791c8", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/team/task.json": "e57a3a804bbc23701002185febd00798b8a149607247a07f86e1d377f5f8388d", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13828,13 +13832,13 @@ "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/task.toml": "b4735f4105307e3ea25c0b16358a53c1e9d0b71beb5656285a839ef3dfad7257", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/task.toml": "1861bfb6bb5dc5c94d541cdd51f6e1603f919316318c84b70a140bbec005f0c0", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/tests/expected.json": "17f119fd38056377e54a61b47ba9a8fad5a18b54bfc148735b69d12454329c47", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/tests/scenario/episode.yaml": "78d72b57c40858e564c73ee1d03161b130ffeea73ba5cbfea7ef80eea31c683a", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/tests/scenario/notes.md": "cec6b3c2fdeb2ba7c13c6cc28959bfd4c15db5b432f23f2a82c369ceb83755ed", "tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/tests/scenario/prefill.json": "787a6b69669d22febd1cdc17c7e5e50b7bdf78fb6e4dae7d461d2fe8a75f1de7", @@ -13854,19 +13858,19 @@ "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/docker-compose.yaml": "8588e3c5d8f9216d6a34cffdc3f4e88f71a40adf584f5800e2535a61e1fe7464", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/team/scenario/episode.yaml": "b4897725ffeb4b2c728f94e3cfc6af86e78d5ae635aab98e5182aa91f924c1ca", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/team/scenario/notes.md": "268d8527bd9816c93254bb30187b94ce024086166df1c6bbb5ca16b36f0d7e69", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/team/scenario/record.json": "dbbec25ae84307437fe1be39222e18dc17e760a7cb24c5dd7d812abe50739393", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/team/scenario/source.md": "bdbb4d0e60060dfd8dcd0cfb6d17e80b14169def14e3791319ae4cd47d69f0bb", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/team/task.json": "0e9a2060e84ef43793b86dc18f146e2a60f788166e10de9ce088a7fb2ef92de2", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/team/task.json": "da4e3dde95f5b24ee28431e8626c59f7a7967565224ece30ef24f559688020c6", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13879,13 +13883,13 @@ "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/task.toml": "f710b2c0ea03e94512666eafc500677c85620dc9232857bb99e951b5ec1d923b", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/task.toml": "47b4ab6b7cf65fd9ab9bfa7b1a2012465a0fbb13314847ea09887c63c0533437", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/tests/expected.json": "cd7b68645ab9121c0b50e73d6b7d362e1d8079b7c4f6ff3ac82105ba7b95f379", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/tests/scenario/episode.yaml": "b4897725ffeb4b2c728f94e3cfc6af86e78d5ae635aab98e5182aa91f924c1ca", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/tests/scenario/notes.md": "268d8527bd9816c93254bb30187b94ce024086166df1c6bbb5ca16b36f0d7e69", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/tests/scenario/record.json": "dbbec25ae84307437fe1be39222e18dc17e760a7cb24c5dd7d812abe50739393", @@ -13904,19 +13908,19 @@ "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/docker-compose.yaml": "08041f1a253a19ee8c7af79afb1a402fd5c1d076a39d10d04600d86ac566776e", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/team/scenario/episode.yaml": "b4897725ffeb4b2c728f94e3cfc6af86e78d5ae635aab98e5182aa91f924c1ca", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/team/scenario/notes.md": "268d8527bd9816c93254bb30187b94ce024086166df1c6bbb5ca16b36f0d7e69", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/team/scenario/record.json": "dbbec25ae84307437fe1be39222e18dc17e760a7cb24c5dd7d812abe50739393", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/team/scenario/source.md": "bdbb4d0e60060dfd8dcd0cfb6d17e80b14169def14e3791319ae4cd47d69f0bb", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/team/task.json": "9ebdf643d6846223481ed1687282ad3003d4a75c23fe02ec7fbebaedb15923b6", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/team/task.json": "9cadc740bd9f82c6525421f0c44c658c9eae4e332ea4f81a92d78db10993fe97", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13929,13 +13933,13 @@ "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/task.toml": "f69f416774ce827a2764696cb830f87eae1e42832ba510c4403f8c16c429ce60", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/task.toml": "aa0935e7351d555e8a0cbcf08bfd1937117f02bb0596bfbd4dfa541db1b27f3f", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/tests/expected.json": "8a4f21125e7f06177f97bde32e42a0612182bf024be172428568f77e7a9427ab", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/tests/scenario/episode.yaml": "b4897725ffeb4b2c728f94e3cfc6af86e78d5ae635aab98e5182aa91f924c1ca", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/tests/scenario/notes.md": "268d8527bd9816c93254bb30187b94ce024086166df1c6bbb5ca16b36f0d7e69", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/tests/scenario/record.json": "dbbec25ae84307437fe1be39222e18dc17e760a7cb24c5dd7d812abe50739393", @@ -13954,20 +13958,20 @@ "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/docker-compose.yaml": "4d29284de3888bb79027a51a1eb198aa04e0138805797b38ab4f9b9c1a92e5a6", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/team/scenario/episode.yaml": "ab16e390371c7adbd23bb3719ef7f0ce83a4f369a925f8ff89e002cec6ea7f17", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/team/scenario/notes.md": "268d8527bd9816c93254bb30187b94ce024086166df1c6bbb5ca16b36f0d7e69", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/team/scenario/prefill.json": "6155683b952c8aa3a6f4b445f80df38c395833eed5adcb74f2a308b0063d1281", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/team/scenario/record.json": "dbbec25ae84307437fe1be39222e18dc17e760a7cb24c5dd7d812abe50739393", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/team/scenario/source.md": "bdbb4d0e60060dfd8dcd0cfb6d17e80b14169def14e3791319ae4cd47d69f0bb", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/team/task.json": "78e76e9f6fcf21f807d5cf26ee768374b752ca773070362a6a6fb0302c49b62b", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/team/task.json": "fdf92cfd9040e081226fcd18e2a5dad80632d7ee720fe971987f77ee63e62284", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -13980,13 +13984,13 @@ "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/task.toml": "4bff68028b0eb726470f2d3f5f08e068869c3a9c7edadd6ef7050a97c1e0d483", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/task.toml": "ef14837c988db37f8072b19c9493941c1fbad9b84762356d63a5b9650567c756", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/tests/expected.json": "34827972c4b7af1223952a24651651141b505f4365c03a31621e70a90cf3af6d", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/tests/scenario/episode.yaml": "ab16e390371c7adbd23bb3719ef7f0ce83a4f369a925f8ff89e002cec6ea7f17", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/tests/scenario/notes.md": "268d8527bd9816c93254bb30187b94ce024086166df1c6bbb5ca16b36f0d7e69", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/tests/scenario/prefill.json": "6155683b952c8aa3a6f4b445f80df38c395833eed5adcb74f2a308b0063d1281", @@ -14006,20 +14010,20 @@ "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/docker-compose.yaml": "e25b67e3adc6450bb167df9d6c99fa1de371301dbe3763432f4e07eae3a6f9b0", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/team/scenario/episode.yaml": "ab16e390371c7adbd23bb3719ef7f0ce83a4f369a925f8ff89e002cec6ea7f17", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/team/scenario/notes.md": "268d8527bd9816c93254bb30187b94ce024086166df1c6bbb5ca16b36f0d7e69", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/team/scenario/prefill.json": "6155683b952c8aa3a6f4b445f80df38c395833eed5adcb74f2a308b0063d1281", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/team/scenario/record.json": "dbbec25ae84307437fe1be39222e18dc17e760a7cb24c5dd7d812abe50739393", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/team/scenario/source.md": "bdbb4d0e60060dfd8dcd0cfb6d17e80b14169def14e3791319ae4cd47d69f0bb", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/team/task.json": "bacff50c36c0b9565d0082deb0e19edf4f31cd951a9e2551cb17f8f181cec82e", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/team/task.json": "73b9e2d759745b3691afa48d3af5a11479b2635016f5bd783bba64959d52964c", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14032,13 +14036,13 @@ "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/task.toml": "315ded51145098eb7c8f5bec72961d606afd582d70ae6323c702f292d888c9d8", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/task.toml": "1b5c63150632593587a3bdacf0f8f008fe899d515f9c36ade75bacaff42bb5db", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/tests/expected.json": "fc3d83c41f65c7287c6c512bfda6ed42fe0ff1b0fcf144424c85755b4dd42521", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/tests/scenario/episode.yaml": "ab16e390371c7adbd23bb3719ef7f0ce83a4f369a925f8ff89e002cec6ea7f17", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/tests/scenario/notes.md": "268d8527bd9816c93254bb30187b94ce024086166df1c6bbb5ca16b36f0d7e69", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/tests/scenario/prefill.json": "6155683b952c8aa3a6f4b445f80df38c395833eed5adcb74f2a308b0063d1281", @@ -14058,20 +14062,20 @@ "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/docker-compose.yaml": "22f6d6a0fbb0bb2a74d7e4168875fc536c90232ed389f32feadd16ab1e5fcdf7", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/team/scenario/episode.yaml": "ab16e390371c7adbd23bb3719ef7f0ce83a4f369a925f8ff89e002cec6ea7f17", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/team/scenario/notes.md": "268d8527bd9816c93254bb30187b94ce024086166df1c6bbb5ca16b36f0d7e69", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/team/scenario/prefill.json": "6155683b952c8aa3a6f4b445f80df38c395833eed5adcb74f2a308b0063d1281", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/team/scenario/record.json": "dbbec25ae84307437fe1be39222e18dc17e760a7cb24c5dd7d812abe50739393", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/team/scenario/source.md": "bdbb4d0e60060dfd8dcd0cfb6d17e80b14169def14e3791319ae4cd47d69f0bb", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/team/task.json": "c2cf146c88d4887d4d785a786d5a15b6c6505eb6ef27b266598af07c99157fac", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/team/task.json": "d6fc5cfe2a39450e307bdb48aade95f2758bedda1587a5e5ecc166e0bc746ead", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14084,13 +14088,13 @@ "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/task.toml": "7ced2e3849de55be928d54a4104b9a34db56dec87df0f792bf40f1bac8fa077d", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/task.toml": "eca5407df0fefb07fd43be35c284d2444e90029003d06ea44a7dcae54c4e43e3", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/tests/expected.json": "0702c7399c111b7c6f2f9cd753cce462ccfa29ce756d6397162f03a0a91e0d51", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/tests/scenario/episode.yaml": "ab16e390371c7adbd23bb3719ef7f0ce83a4f369a925f8ff89e002cec6ea7f17", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/tests/scenario/notes.md": "268d8527bd9816c93254bb30187b94ce024086166df1c6bbb5ca16b36f0d7e69", "tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/tests/scenario/prefill.json": "6155683b952c8aa3a6f4b445f80df38c395833eed5adcb74f2a308b0063d1281", @@ -14110,19 +14114,19 @@ "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/docker-compose.yaml": "ace9a6eb04316d8dd38f1073992cc99bf9d4ae4b3d53cd8e6001b8fd895c0751", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/team/scenario/episode.yaml": "9ad34bbba2a7323449071ad352224ea02addcd3a4fd32df0726047ef37ccd51b", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/team/scenario/notes.md": "686004c9118652fc1ec1529db4ffaa9bbd480959141ea80aeb2fc887a9555362", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/team/scenario/record.json": "233afe213baa694ef13b20368177bd062bc1b7586f3a4af1ae42ee48b898fccc", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/team/scenario/source.md": "f1f00382b6cbd2e4398c0442abadae6aaaca157c2a2c3ae9bae68b55064f10da", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/team/task.json": "eb9608d3afdbcf4add60f89ef6b8133cdfaa8ee2d4f6b913bdef89cac8c493ef", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/team/task.json": "d9d183bc0ccde369c8535a4a5367f0ce49bce3256bef0043071f9d85baff3068", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14135,13 +14139,13 @@ "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/task.toml": "98c72d6cc6fe680da31f884d1ae9496e8a0eb3ea650a81a18475b5e8f9d34601", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/task.toml": "c795a43218c492e5c02b03fb671811a8474e445b0a1155bcb22e681775dd5318", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/tests/expected.json": "e93f8d5b435c5317791b78f64e74e00586bbb49493dd90ca823b011c11933bc0", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/tests/scenario/episode.yaml": "9ad34bbba2a7323449071ad352224ea02addcd3a4fd32df0726047ef37ccd51b", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/tests/scenario/notes.md": "686004c9118652fc1ec1529db4ffaa9bbd480959141ea80aeb2fc887a9555362", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/tests/scenario/record.json": "233afe213baa694ef13b20368177bd062bc1b7586f3a4af1ae42ee48b898fccc", @@ -14160,19 +14164,19 @@ "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/docker-compose.yaml": "c791d7049a1c156df981d6497c0fbff6fbea1af37d7f6038773f19586ac8f753", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/team/scenario/episode.yaml": "9ad34bbba2a7323449071ad352224ea02addcd3a4fd32df0726047ef37ccd51b", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/team/scenario/notes.md": "686004c9118652fc1ec1529db4ffaa9bbd480959141ea80aeb2fc887a9555362", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/team/scenario/record.json": "233afe213baa694ef13b20368177bd062bc1b7586f3a4af1ae42ee48b898fccc", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/team/scenario/source.md": "f1f00382b6cbd2e4398c0442abadae6aaaca157c2a2c3ae9bae68b55064f10da", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/team/task.json": "f84d703cd6e60aea8e09075f476c49931cf3cf3d49cd12919cf1127748145525", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/team/task.json": "96ad4717ca2edfca6f519debc071628dbc20614a02bb532de4151dcf6700a727", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14185,13 +14189,13 @@ "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/task.toml": "aae2bcf70b4a31e4743ebe3255be4790dcccb72409cf583b6ca62e9f7b56848b", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/task.toml": "def61ff6d2ca3a87e5e09c5a6debd1f1bf7400a7d4de553709400c3b661457a7", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/tests/expected.json": "fc02a3f32849fe4df552c6014ebe87acfe2a5ebc837583942c9fd50fac6b0106", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/tests/scenario/episode.yaml": "9ad34bbba2a7323449071ad352224ea02addcd3a4fd32df0726047ef37ccd51b", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/tests/scenario/notes.md": "686004c9118652fc1ec1529db4ffaa9bbd480959141ea80aeb2fc887a9555362", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/tests/scenario/record.json": "233afe213baa694ef13b20368177bd062bc1b7586f3a4af1ae42ee48b898fccc", @@ -14210,20 +14214,20 @@ "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/docker-compose.yaml": "6e1b68a2ff9154cb5458d3dd7ff51f6e8ebdbe6213cd715b2b6d8b281976c85a", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/team/scenario/episode.yaml": "07b75cd4770d3ef2198cff2758a0e6abaeacea72154a06bc49b32d0e2251550b", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/team/scenario/notes.md": "686004c9118652fc1ec1529db4ffaa9bbd480959141ea80aeb2fc887a9555362", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/team/scenario/prefill.json": "d443ea544d0e22775859d57764ae2eea18bcabd70018d869aa326bbda3699aee", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/team/scenario/record.json": "233afe213baa694ef13b20368177bd062bc1b7586f3a4af1ae42ee48b898fccc", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/team/scenario/source.md": "f1f00382b6cbd2e4398c0442abadae6aaaca157c2a2c3ae9bae68b55064f10da", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/team/task.json": "45a05c38fad07219e86fc0e639769c5d12e370f874f0c70defdb650bd8c30747", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/team/task.json": "c80e6fa7350d143fd200958d2da3b8de6ebd5c2a781f3d3b32887df68668fff0", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14236,13 +14240,13 @@ "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/task.toml": "47e45f54717954cd72f869dea82580f61d3d913004b44b78470447215b8de6e1", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/task.toml": "fe8b6a68d9dbc00d4e084fd938a8ecfd5fbe5f12824cf5ccd409586b87c1fe34", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/tests/expected.json": "46710364c5d24a2fc38e55b5294fbf7b4ee4d3622fce95f118e8b3bb1c9d63d5", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/tests/scenario/episode.yaml": "07b75cd4770d3ef2198cff2758a0e6abaeacea72154a06bc49b32d0e2251550b", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/tests/scenario/notes.md": "686004c9118652fc1ec1529db4ffaa9bbd480959141ea80aeb2fc887a9555362", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/tests/scenario/prefill.json": "d443ea544d0e22775859d57764ae2eea18bcabd70018d869aa326bbda3699aee", @@ -14262,20 +14266,20 @@ "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/docker-compose.yaml": "e8a39a9bc8e8233c8da49100908cfebe4429256c3a21c693ec1df39a7dce86e6", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/team/scenario/episode.yaml": "07b75cd4770d3ef2198cff2758a0e6abaeacea72154a06bc49b32d0e2251550b", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/team/scenario/notes.md": "686004c9118652fc1ec1529db4ffaa9bbd480959141ea80aeb2fc887a9555362", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/team/scenario/prefill.json": "d443ea544d0e22775859d57764ae2eea18bcabd70018d869aa326bbda3699aee", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/team/scenario/record.json": "233afe213baa694ef13b20368177bd062bc1b7586f3a4af1ae42ee48b898fccc", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/team/scenario/source.md": "f1f00382b6cbd2e4398c0442abadae6aaaca157c2a2c3ae9bae68b55064f10da", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/team/task.json": "10105b8cc676431b9cbb9018375451f08623aba041f2dae075f80c86b3687722", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/team/task.json": "80ee81dc9b8f776ebb32fb8e6bc1465418aa7c15a2b4f69acdf64dab7bd61e6f", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14288,13 +14292,13 @@ "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/task.toml": "b56e77b733762b4defe754a62cdb2a6deaded697d04d8eea104afb681c284d0b", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/task.toml": "b25d359875076da1c3122a84d314bf5818c7fab463d347962f190eea1d59f84f", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/tests/expected.json": "7bf53d6a7aba86eea2757bda0fda0b93cffabfbe8ced192d99338d85ece99796", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/tests/scenario/episode.yaml": "07b75cd4770d3ef2198cff2758a0e6abaeacea72154a06bc49b32d0e2251550b", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/tests/scenario/notes.md": "686004c9118652fc1ec1529db4ffaa9bbd480959141ea80aeb2fc887a9555362", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/tests/scenario/prefill.json": "d443ea544d0e22775859d57764ae2eea18bcabd70018d869aa326bbda3699aee", @@ -14314,20 +14318,20 @@ "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/docker-compose.yaml": "09541cf0aa2c84b00de8dbef605ac817aec085490397e86b1a48974c572750a8", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/team/scenario/episode.yaml": "07b75cd4770d3ef2198cff2758a0e6abaeacea72154a06bc49b32d0e2251550b", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/team/scenario/notes.md": "686004c9118652fc1ec1529db4ffaa9bbd480959141ea80aeb2fc887a9555362", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/team/scenario/prefill.json": "d443ea544d0e22775859d57764ae2eea18bcabd70018d869aa326bbda3699aee", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/team/scenario/record.json": "233afe213baa694ef13b20368177bd062bc1b7586f3a4af1ae42ee48b898fccc", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/team/scenario/source.md": "f1f00382b6cbd2e4398c0442abadae6aaaca157c2a2c3ae9bae68b55064f10da", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/team/task.json": "923491bfd31581815d988888f15af39eaade1a49010fbeddefd33900e2346889", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/team/task.json": "98377836b2b1e509dad280f85ddd3d6dcd1108fca3f6637a9c1ca2dbf7b7afc3", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14340,13 +14344,13 @@ "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/task.toml": "4aa083e5fab5a9186f5e041037860b721a3f0317edaccb7de73ab676c3511730", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/task.toml": "5b361df6a74e77eb5013330b6d8c6f58207899ae6e7a02625cc1250810e6305d", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/tests/expected.json": "df69cd1d46434f1a035d8f286c7c491cde2ae39248788a81971a549ae6a33908", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/tests/scenario/episode.yaml": "07b75cd4770d3ef2198cff2758a0e6abaeacea72154a06bc49b32d0e2251550b", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/tests/scenario/notes.md": "686004c9118652fc1ec1529db4ffaa9bbd480959141ea80aeb2fc887a9555362", "tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/tests/scenario/prefill.json": "d443ea544d0e22775859d57764ae2eea18bcabd70018d869aa326bbda3699aee", @@ -14366,14 +14370,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/docker-compose.yaml": "d6b09235aef03f2adf5f1c22bfeeb16475fddb7beb22d0fcbeb6ab99f3a521e3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/team/scenario/episode.yaml": "c4a21ee1478b7b97f3194404bae3f84037551ba2f1c4c46eb0b6ad5de64696f5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/team/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/team/scenario/raw/lcbhard_0_oneoff_test.txt": "791c8c64fa50d39b9c938344abec7086a52fafc65538bf40b42d58a409181f5d", @@ -14382,7 +14386,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/team/scenario/raw/lcbhard_0_rows.json": "9f66964bca918f0787f75fd70852976afd277391a245b06e692d8c8d20cb700d", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/team/scenario/record.json": "ec69d7d48a87c1bceeb5b366edaf2b4f0b7c8468b6e334acd17ae12e543bc3c1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/team/scenario/source.md": "2faafcf6a2c5df1ce6c6bd301a35dab10e5bede32fe31f449ef5a713ec5460c6", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/team/task.json": "6096a6fe469c3ba7f9cf9bf826f2d597e1b0e48f4e9a872260ca1ec72ef257a0", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/team/task.json": "c2068eb381585dfea998404ebfcf62301fa76e702a7a70b419985579757bc291", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14395,13 +14399,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/task.toml": "cba53da431e0fa0542ee25b8cd6ad2b1a87af0095edf36e3f63f5c9db018592e", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/task.toml": "288800837a39ca1bb5433f14f898a511409fe3961762f9854bfc4899498500f4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/tests/expected.json": "29068be780a5f18122c553a902d43067985a896400d4546ff83ae26477f4bb4d", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/tests/scenario/episode.yaml": "c4a21ee1478b7b97f3194404bae3f84037551ba2f1c4c46eb0b6ad5de64696f5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/tests/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/tests/scenario/raw/lcbhard_0_oneoff_test.txt": "791c8c64fa50d39b9c938344abec7086a52fafc65538bf40b42d58a409181f5d", @@ -14424,14 +14428,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/docker-compose.yaml": "a1b4568d4e69c2c1dcdde2fb0a24b9b33957aa4981aa18718b87eb9a3f328feb", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/team/scenario/episode.yaml": "c4a21ee1478b7b97f3194404bae3f84037551ba2f1c4c46eb0b6ad5de64696f5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/team/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/team/scenario/raw/lcbhard_0_oneoff_test.txt": "791c8c64fa50d39b9c938344abec7086a52fafc65538bf40b42d58a409181f5d", @@ -14440,7 +14444,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/team/scenario/raw/lcbhard_0_rows.json": "9f66964bca918f0787f75fd70852976afd277391a245b06e692d8c8d20cb700d", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/team/scenario/record.json": "ec69d7d48a87c1bceeb5b366edaf2b4f0b7c8468b6e334acd17ae12e543bc3c1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/team/scenario/source.md": "2faafcf6a2c5df1ce6c6bd301a35dab10e5bede32fe31f449ef5a713ec5460c6", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/team/task.json": "b1d4b4d6bbf5b34018eecd5581ea528fc55c319fbd3a9a5835dfccc94c6fd62b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/team/task.json": "5964dd4351324dda25b2ab805ac6b6109848ae30264c3183a8d36400af7b9ba1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14453,13 +14457,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/task.toml": "ecd2922b5462b6ca8eb655f3d932aea69b2703d366a5d130d1df37095ae6a60f", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/task.toml": "3f3e90b10758c400bfa8cfc951d6c4ddab31f50db43937ea90d0b77ffc90a5ca", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/tests/expected.json": "effb2a69d50e1d9624e2c7587ae5772e9a2e411a3ee6b7876a0051fc603f10ca", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/tests/scenario/episode.yaml": "c4a21ee1478b7b97f3194404bae3f84037551ba2f1c4c46eb0b6ad5de64696f5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/tests/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/tests/scenario/raw/lcbhard_0_oneoff_test.txt": "791c8c64fa50d39b9c938344abec7086a52fafc65538bf40b42d58a409181f5d", @@ -14482,20 +14486,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/docker-compose.yaml": "47b2aeae9655b7de9f083f05a32ee077400157dcd6d8a68da80ff13950da3568", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/team/scenario/episode.yaml": "974b62fb050edd9b08df66be06287a68620ba425df56a70c21c1e7806f9f91e1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/team/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/team/scenario/prefill.json": "3f8edb61550c0b9581345a1df924fc675dfbf5cddca6f39683b1030a370f863c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/team/scenario/record.json": "ec69d7d48a87c1bceeb5b366edaf2b4f0b7c8468b6e334acd17ae12e543bc3c1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/team/scenario/source.md": "2faafcf6a2c5df1ce6c6bd301a35dab10e5bede32fe31f449ef5a713ec5460c6", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/team/task.json": "9efa5f8d132754878b33c8173f2e91c5cd69423d11634ab1301cc53eafd2bc07", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/team/task.json": "944c91f83125b3d3ecaab3097461d376f4ee3bbdbb5f0248e76da051ef4d02eb", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14508,13 +14512,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/task.toml": "56d9d690b8b03fb861343f1cdffe3e0d679597439c4bdc25afda94c14f443089", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/task.toml": "f379a5be812af2c0bd046f50ae32888cb2fd971bfb6f23cf1f7d42c7f1505287", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/tests/expected.json": "b311151dd3f4143fefdfd2c332ccb19c23df450eb913b090dce7a2441fed0c28", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/tests/scenario/episode.yaml": "974b62fb050edd9b08df66be06287a68620ba425df56a70c21c1e7806f9f91e1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/tests/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/tests/scenario/prefill.json": "3f8edb61550c0b9581345a1df924fc675dfbf5cddca6f39683b1030a370f863c", @@ -14534,20 +14538,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/docker-compose.yaml": "8967b744bb098e78079228e3a189c67ca9389ac094f630f5fcf2a500eb07a6e1", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/team/scenario/episode.yaml": "974b62fb050edd9b08df66be06287a68620ba425df56a70c21c1e7806f9f91e1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/team/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/team/scenario/prefill.json": "3f8edb61550c0b9581345a1df924fc675dfbf5cddca6f39683b1030a370f863c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/team/scenario/record.json": "ec69d7d48a87c1bceeb5b366edaf2b4f0b7c8468b6e334acd17ae12e543bc3c1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/team/scenario/source.md": "2faafcf6a2c5df1ce6c6bd301a35dab10e5bede32fe31f449ef5a713ec5460c6", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/team/task.json": "54e47a04a3fa6869691b376b366dcc330c7604897e5662cf7f82345fb299a1e8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/team/task.json": "29bf75fb33b6fe1d30d96c6556c5e07c294c5f7bb8e0274774cf48483b963347", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14560,13 +14564,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/task.toml": "ff72213cf5ee4570a74a387c75c9f7e8c03979f33f5ae1216e67a1a6475a4bf5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/task.toml": "8063c28e61acb1656996b53fda9301b084fd1c376930c5b07524ac0126fa23b7", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/tests/expected.json": "ae333b8d8f0ded8e02d1e65d11a0c798216dfbac7c44f2846f0dc7b7380f3772", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/tests/scenario/episode.yaml": "974b62fb050edd9b08df66be06287a68620ba425df56a70c21c1e7806f9f91e1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/tests/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/tests/scenario/prefill.json": "3f8edb61550c0b9581345a1df924fc675dfbf5cddca6f39683b1030a370f863c", @@ -14586,20 +14590,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/docker-compose.yaml": "6c3e3d931b5adce3f34ced675f6c26f91c9b9ca0aa4361750438505b63f6be3d", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/team/scenario/episode.yaml": "974b62fb050edd9b08df66be06287a68620ba425df56a70c21c1e7806f9f91e1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/team/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/team/scenario/prefill.json": "3f8edb61550c0b9581345a1df924fc675dfbf5cddca6f39683b1030a370f863c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/team/scenario/record.json": "ec69d7d48a87c1bceeb5b366edaf2b4f0b7c8468b6e334acd17ae12e543bc3c1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/team/scenario/source.md": "2faafcf6a2c5df1ce6c6bd301a35dab10e5bede32fe31f449ef5a713ec5460c6", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/team/task.json": "cd9f73b863c34b6892109458f768c1312b3e8bb97535b866f4b931c3492a4dc5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/team/task.json": "2899e589cb06cf6c3ced929d5c4bb42dfeaae3945e9627e6d4b536766277ce23", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14612,13 +14616,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/task.toml": "b73d159a868291dba369c855a28697cb3f56118b680deb2f7651b94408980c8f", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/task.toml": "120b20b78b3f0f8d32ab9b1d83512c0fe73202dee774e0b4aa514389b03db421", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/tests/expected.json": "be718c142e6a8e14962c4a1789a3fe467935b38ed2a98fa542dd301d54cf798b", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/tests/scenario/episode.yaml": "974b62fb050edd9b08df66be06287a68620ba425df56a70c21c1e7806f9f91e1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/tests/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/tests/scenario/prefill.json": "3f8edb61550c0b9581345a1df924fc675dfbf5cddca6f39683b1030a370f863c", @@ -14638,14 +14642,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/docker-compose.yaml": "3c8e698212d27df722d1c330c66c24baba742198bdd4def278ecbb7c6984494d", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/team/scenario/episode.yaml": "c4a21ee1478b7b97f3194404bae3f84037551ba2f1c4c46eb0b6ad5de64696f5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/team/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/team/scenario/raw/lcbhard_0_oneoff_test.txt": "791c8c64fa50d39b9c938344abec7086a52fafc65538bf40b42d58a409181f5d", @@ -14654,7 +14658,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/team/scenario/raw/lcbhard_0_rows.json": "9f66964bca918f0787f75fd70852976afd277391a245b06e692d8c8d20cb700d", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/team/scenario/record.json": "ec69d7d48a87c1bceeb5b366edaf2b4f0b7c8468b6e334acd17ae12e543bc3c1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/team/scenario/source.md": "2faafcf6a2c5df1ce6c6bd301a35dab10e5bede32fe31f449ef5a713ec5460c6", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/team/task.json": "0298294e9ca578ba2b8927460fb921d6c10989d01caf644a5bb78377a32d3955", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/team/task.json": "ed46236e3c8bfaf6c2069f4fd8bf7f271b72528c44a21d2a0d5d1422ddfb5ab4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14667,13 +14671,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/task.toml": "4a55ab9ac45d91ec3a233a4f31c43ab7b34cd1cf1fd2f62756857bed98a92d03", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/task.toml": "2f6f9e96050177e70870f0b6292d2124d66f6555f1169c6478a33d8d5064c307", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/tests/expected.json": "9dbef0cdc682f1b4d8c63b8250e22cfb0e35dce72af9b7e917e69db2d1283c2f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/tests/scenario/episode.yaml": "c4a21ee1478b7b97f3194404bae3f84037551ba2f1c4c46eb0b6ad5de64696f5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/tests/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/tests/scenario/raw/lcbhard_0_oneoff_test.txt": "791c8c64fa50d39b9c938344abec7086a52fafc65538bf40b42d58a409181f5d", @@ -14696,14 +14700,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/docker-compose.yaml": "cdc90e149c8025e1fcdcd5d5732d4cac79f37df2d7d44c96fe8b8361552d0cb1", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/team/scenario/episode.yaml": "c4a21ee1478b7b97f3194404bae3f84037551ba2f1c4c46eb0b6ad5de64696f5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/team/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/team/scenario/raw/lcbhard_0_oneoff_test.txt": "791c8c64fa50d39b9c938344abec7086a52fafc65538bf40b42d58a409181f5d", @@ -14712,7 +14716,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/team/scenario/raw/lcbhard_0_rows.json": "9f66964bca918f0787f75fd70852976afd277391a245b06e692d8c8d20cb700d", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/team/scenario/record.json": "ec69d7d48a87c1bceeb5b366edaf2b4f0b7c8468b6e334acd17ae12e543bc3c1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/team/scenario/source.md": "2faafcf6a2c5df1ce6c6bd301a35dab10e5bede32fe31f449ef5a713ec5460c6", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/team/task.json": "1be1a6893196ed0d65e5e42bdb2e251ce193f6755027c0279d8184c87754d1a8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/team/task.json": "8ba40a9d51a777b13226856e4727e2d465c2b681b2096a1d89f4592a0827c8b3", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14725,13 +14729,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/task.toml": "1d24ec8b253d74e4d8d1a8c68673687683291b8563b5ae4b9ec73b45b8c3af18", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/task.toml": "d6cca08588fcdb110fd3f36a693ce07362de32ace8ed9d78cb1b80dcb3d53273", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/tests/expected.json": "53f2d0d045a14e0b7f686cdde0a4571ca41ddeab7e2cfe6d3b99ed417cf7b48c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/tests/scenario/episode.yaml": "c4a21ee1478b7b97f3194404bae3f84037551ba2f1c4c46eb0b6ad5de64696f5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/tests/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/tests/scenario/raw/lcbhard_0_oneoff_test.txt": "791c8c64fa50d39b9c938344abec7086a52fafc65538bf40b42d58a409181f5d", @@ -14754,20 +14758,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/docker-compose.yaml": "e3ef10320ceab202cc0fbb2108cd9e1494e0b2ef6e5c17bed24ffef1d620529e", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/team/scenario/episode.yaml": "3446ba190618392e51deffbac4076ba6e5c314f9197857a900ae7735fe89d590", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/team/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/team/scenario/prefill.json": "3230dca65a6996db11196ac9516cd2740373ad08e1290c2cb7204b35a98b1cc4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/team/scenario/record.json": "ec69d7d48a87c1bceeb5b366edaf2b4f0b7c8468b6e334acd17ae12e543bc3c1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/team/scenario/source.md": "2faafcf6a2c5df1ce6c6bd301a35dab10e5bede32fe31f449ef5a713ec5460c6", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/team/task.json": "3af7f94caaad7a447888bb2f0f67a9df8f06ca5cafa03bc36be445cdd20be3a8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/team/task.json": "0cadfa7e42d4c9ed5086d880a0dabbd215807aa6b2e262c153859ab484c3b6d9", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14780,13 +14784,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/task.toml": "4293ffd04092840f2d8b6e11dce292969b5ff754fd15e6a882b7b9a114a95fcf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/task.toml": "4dd7b7f34dea89bc3ee1fcbe92e5471cee264644e3a97f14563a48da54625984", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/tests/expected.json": "67c7e050f32bd4f3dc169774fc5eae07e6ced98a9e45e7ef3bd4cbb6c891aaf7", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/tests/scenario/episode.yaml": "3446ba190618392e51deffbac4076ba6e5c314f9197857a900ae7735fe89d590", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/tests/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/tests/scenario/prefill.json": "3230dca65a6996db11196ac9516cd2740373ad08e1290c2cb7204b35a98b1cc4", @@ -14806,20 +14810,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/docker-compose.yaml": "00a3ca55646d34dc48a5c6c30910fa7c933f80403f9eeb425c8ec46c8d18e2f0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/team/scenario/episode.yaml": "3446ba190618392e51deffbac4076ba6e5c314f9197857a900ae7735fe89d590", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/team/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/team/scenario/prefill.json": "3230dca65a6996db11196ac9516cd2740373ad08e1290c2cb7204b35a98b1cc4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/team/scenario/record.json": "ec69d7d48a87c1bceeb5b366edaf2b4f0b7c8468b6e334acd17ae12e543bc3c1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/team/scenario/source.md": "2faafcf6a2c5df1ce6c6bd301a35dab10e5bede32fe31f449ef5a713ec5460c6", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/team/task.json": "fcfd7d6540e493373cff02f2e98cfcdf72d34e809f4e204f25869c3e4d66b2f1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/team/task.json": "111522dd442616769914933b0e2ff449d900dafb91926c13c2ef5ad529a23ca3", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14832,13 +14836,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/task.toml": "610a7dc4d706733569bb544a9cda670165c1dc3e9add2e7d247cb13b39f8b6cb", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/task.toml": "ef13afc7c7d2b84fc210e818018e1cea6959131033cc2b08b7c7f1293fd25843", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/tests/expected.json": "817dd647547fa7534aa89ad98da21aecd4d29958e4def62e79ed10e9766202b0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/tests/scenario/episode.yaml": "3446ba190618392e51deffbac4076ba6e5c314f9197857a900ae7735fe89d590", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/tests/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/tests/scenario/prefill.json": "3230dca65a6996db11196ac9516cd2740373ad08e1290c2cb7204b35a98b1cc4", @@ -14858,20 +14862,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/docker-compose.yaml": "386b7ba651aa3e51c12881051c791455e97ceb89673a713ad8969bf415175a6e", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/team/scenario/episode.yaml": "3446ba190618392e51deffbac4076ba6e5c314f9197857a900ae7735fe89d590", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/team/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/team/scenario/prefill.json": "3230dca65a6996db11196ac9516cd2740373ad08e1290c2cb7204b35a98b1cc4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/team/scenario/record.json": "ec69d7d48a87c1bceeb5b366edaf2b4f0b7c8468b6e334acd17ae12e543bc3c1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/team/scenario/source.md": "2faafcf6a2c5df1ce6c6bd301a35dab10e5bede32fe31f449ef5a713ec5460c6", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/team/task.json": "69725ebb265fe9b3d888e18bd80db615a187481c84456cfa2490ac06594e10aa", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/team/task.json": "71d79e91c13bf2b1c322c0b96a6c255e19b228bbe5fcc33a59bd7c7cbec3db7d", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14884,13 +14888,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/task.toml": "5f4d5c49df146bb0a79720336a31c1bd5a1b7fbeb36d37fb72c28efc57736e06", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/task.toml": "cf0a48182c0b68cc5b15d880c427891296c728d576383723a02be7fd2cda6444", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/tests/expected.json": "77580b1d65187f05dfdf2dea8c0803ca8912bbcc4094ec7ab38b282d50a55a37", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/tests/scenario/episode.yaml": "3446ba190618392e51deffbac4076ba6e5c314f9197857a900ae7735fe89d590", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/tests/scenario/notes.md": "03d05a5bb30f6bca18501d610367179e8b3d298f67c6396906376622577bebed", "tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/tests/scenario/prefill.json": "3230dca65a6996db11196ac9516cd2740373ad08e1290c2cb7204b35a98b1cc4", @@ -14910,14 +14914,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/docker-compose.yaml": "e8eb48a86950801984b4bc0717e5043bab89334c81e273d12cf57a589ef4de57", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/team/scenario/episode.yaml": "55a5f26774fc6819b1e627b9c03a634cdd7f394dce6836db400434e240fb01ca", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/team/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/team/scenario/raw/lcbhard_1_oneoff_test.txt": "5497a5b8566ecad6d822784f9722ce1fcaba0faaf64d897827a07033f2752610", @@ -14926,7 +14930,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/team/scenario/raw/lcbhard_1_rows.json": "007d9c1691d096b7b4d5fececaf9d6037ae0c9fd17fff842cf1fc953c738c3ce", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/team/scenario/record.json": "c4b761ea017764d08851353cb3e0ea3e99b7105857d78b0f3e54bf6bcada1b90", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/team/scenario/source.md": "a8842add47e71e2752e25264cc94be7ba67b70bf475e0219c285172729457d85", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/team/task.json": "0536900f2139ff6055275f3bbb1921b67eb09a23f3eaf2c282c16225c30624fd", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/team/task.json": "608801f8dc214ead8dcbf8ec95a6a22dc6ebee3b3e9e357c6cca97ac6a51e9e0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14939,13 +14943,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/task.toml": "6768f227445acde14b6e26f6929a216e3b6596c638e9ab84a2cdce2c68e32e40", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/task.toml": "718ce23e779418f02eee24a4b9694d0eabc393d49afd575443f62ec5143ffbf8", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/tests/expected.json": "1996f2a81feabfdef5b5b0eb254b2fd475cce1fd50a78c7b2a1f247c0579e6e9", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/tests/scenario/episode.yaml": "55a5f26774fc6819b1e627b9c03a634cdd7f394dce6836db400434e240fb01ca", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/tests/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/tests/scenario/raw/lcbhard_1_oneoff_test.txt": "5497a5b8566ecad6d822784f9722ce1fcaba0faaf64d897827a07033f2752610", @@ -14968,14 +14972,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/docker-compose.yaml": "98b4ce726b430aa66079e84d76d9234fd2ff3f24c43c3a382cdd4161a151b520", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/team/scenario/episode.yaml": "55a5f26774fc6819b1e627b9c03a634cdd7f394dce6836db400434e240fb01ca", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/team/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/team/scenario/raw/lcbhard_1_oneoff_test.txt": "5497a5b8566ecad6d822784f9722ce1fcaba0faaf64d897827a07033f2752610", @@ -14984,7 +14988,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/team/scenario/raw/lcbhard_1_rows.json": "007d9c1691d096b7b4d5fececaf9d6037ae0c9fd17fff842cf1fc953c738c3ce", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/team/scenario/record.json": "c4b761ea017764d08851353cb3e0ea3e99b7105857d78b0f3e54bf6bcada1b90", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/team/scenario/source.md": "a8842add47e71e2752e25264cc94be7ba67b70bf475e0219c285172729457d85", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/team/task.json": "0e0107cfa9860cb1ae3d01d6417d0204996d335e9e275b8e1da2457023b84e73", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/team/task.json": "9bdd6d4872bf7dcb86850bddb174d5064ba8639c72e7e73a9eb082c19a4c9bdb", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -14997,13 +15001,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/task.toml": "cda4015af10dcfc1ca14981d53d98a1e9abcc4f2f4bb524a17be4d24663378c3", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/task.toml": "ea2a60bf97691ddfcb7a1a8dc02b7c7dd80cb7aa319639189b0d2be2150a35bb", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/tests/expected.json": "750d449cf06ac5511909b98f3783de5ef441db2aeafc82f4d24e7c77b9055d52", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/tests/scenario/episode.yaml": "55a5f26774fc6819b1e627b9c03a634cdd7f394dce6836db400434e240fb01ca", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/tests/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/tests/scenario/raw/lcbhard_1_oneoff_test.txt": "5497a5b8566ecad6d822784f9722ce1fcaba0faaf64d897827a07033f2752610", @@ -15026,20 +15030,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/docker-compose.yaml": "d3bdedab2322a032fdf667af7b77d764c61fae93e4755c2ded5f38e1f8f4a3d9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/team/scenario/episode.yaml": "b1a7775c75db43d1fa902fec09dfc83096a79e7e91910263ac4112570fc5b0ac", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/team/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/team/scenario/prefill.json": "37bbb3c22b7408a12cbe75206d01269305e1c5da476ffc03995fc525f3c093e5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/team/scenario/record.json": "c4b761ea017764d08851353cb3e0ea3e99b7105857d78b0f3e54bf6bcada1b90", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/team/scenario/source.md": "a8842add47e71e2752e25264cc94be7ba67b70bf475e0219c285172729457d85", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/team/task.json": "80cd0b40f4eccbe3abc572186b143e551778eb42d27c4579a10580bc1ad18c96", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/team/task.json": "f27f91375692ca5a3a084c103c5272c3d56e7a51b4262b410e0f6eecbaeee51f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15052,13 +15056,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/task.toml": "c783da863b33e18ad041664c6dcad43e5aac6bbce71723d2b2921677f5dc0aa5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/task.toml": "681d9c233307fcf9b92225b3bfcddf91ea357f56a40374eeb9fd2470a432cf68", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/tests/expected.json": "641b11a8d4333074dd11b7c99090fc0d22f38eb2e6fc7616f239325248d07745", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/tests/scenario/episode.yaml": "b1a7775c75db43d1fa902fec09dfc83096a79e7e91910263ac4112570fc5b0ac", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/tests/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/tests/scenario/prefill.json": "37bbb3c22b7408a12cbe75206d01269305e1c5da476ffc03995fc525f3c093e5", @@ -15078,20 +15082,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/docker-compose.yaml": "0ef039fd5b7a20af7628126c5b919b007f82b9e4d374b1b8924107a7e12bae7d", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/team/scenario/episode.yaml": "b1a7775c75db43d1fa902fec09dfc83096a79e7e91910263ac4112570fc5b0ac", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/team/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/team/scenario/prefill.json": "37bbb3c22b7408a12cbe75206d01269305e1c5da476ffc03995fc525f3c093e5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/team/scenario/record.json": "c4b761ea017764d08851353cb3e0ea3e99b7105857d78b0f3e54bf6bcada1b90", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/team/scenario/source.md": "a8842add47e71e2752e25264cc94be7ba67b70bf475e0219c285172729457d85", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/team/task.json": "73c4a6a25e0f945e56639b2f5f272f37ceca81fa9aaa9fc55b313534ce0ca4cf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/team/task.json": "72ecc538775cc364f93694b7a3f34a7ad0bbfd433eec58a523197684dba69823", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15104,13 +15108,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/task.toml": "4b03e6cee94a86253abc0b1d557a9ccf9fc5f26ec44ac96c6da9e3cf2f96015a", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/task.toml": "6b070a0866c9ebc04f1b84360a971aeb9be26a0f52024d674eb6144d6371432f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/tests/expected.json": "844a1db10c14f415b907730711cee1bffa3c66225acb6b8d6a08294a7b112b5e", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/tests/scenario/episode.yaml": "b1a7775c75db43d1fa902fec09dfc83096a79e7e91910263ac4112570fc5b0ac", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/tests/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/tests/scenario/prefill.json": "37bbb3c22b7408a12cbe75206d01269305e1c5da476ffc03995fc525f3c093e5", @@ -15130,20 +15134,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/docker-compose.yaml": "212ec4142fa4da1167d60d42ebc9e7f132b77b25ab5e379ec22c7306ffb4c9dc", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/team/scenario/episode.yaml": "b1a7775c75db43d1fa902fec09dfc83096a79e7e91910263ac4112570fc5b0ac", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/team/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/team/scenario/prefill.json": "37bbb3c22b7408a12cbe75206d01269305e1c5da476ffc03995fc525f3c093e5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/team/scenario/record.json": "c4b761ea017764d08851353cb3e0ea3e99b7105857d78b0f3e54bf6bcada1b90", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/team/scenario/source.md": "a8842add47e71e2752e25264cc94be7ba67b70bf475e0219c285172729457d85", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/team/task.json": "fe72389d7d96a4844c36a80329d3ead7aa95def9acdc7bf3e96f3908ff2e3aca", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/team/task.json": "96a4b65b467ccf09c009c3c846456ca9e853a83e6a9cd097d4cfe06e8b82989f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15156,13 +15160,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/task.toml": "0e461f8c258dbb2a013e16d0e09d9f64021b05f3274a72ecf2febeeb06635ddc", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/task.toml": "477d29a8325ac4078590734fa586fe4378159efa311a43fb8326dffbaefafee4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/tests/expected.json": "2279b44c3ddeb0153a82a80b5b6f922e9b96f8c083f98fd17594d417a4965269", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/tests/scenario/episode.yaml": "b1a7775c75db43d1fa902fec09dfc83096a79e7e91910263ac4112570fc5b0ac", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/tests/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/tests/scenario/prefill.json": "37bbb3c22b7408a12cbe75206d01269305e1c5da476ffc03995fc525f3c093e5", @@ -15182,14 +15186,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/docker-compose.yaml": "b50309aa6ca7bb50ab3a28168ba665619c13a69dac594b0278d63347f7e73195", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/team/scenario/episode.yaml": "55a5f26774fc6819b1e627b9c03a634cdd7f394dce6836db400434e240fb01ca", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/team/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/team/scenario/raw/lcbhard_1_oneoff_test.txt": "5497a5b8566ecad6d822784f9722ce1fcaba0faaf64d897827a07033f2752610", @@ -15198,7 +15202,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/team/scenario/raw/lcbhard_1_rows.json": "007d9c1691d096b7b4d5fececaf9d6037ae0c9fd17fff842cf1fc953c738c3ce", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/team/scenario/record.json": "c4b761ea017764d08851353cb3e0ea3e99b7105857d78b0f3e54bf6bcada1b90", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/team/scenario/source.md": "a8842add47e71e2752e25264cc94be7ba67b70bf475e0219c285172729457d85", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/team/task.json": "13c0cff4b5e37acc8dde55c0cd7d37ded4fbc58eac8d2a2cc21d79d2968a9ad4", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/team/task.json": "91d7e358377009b8947d56deeb852a1692072e79878d68cdd10a2a17646540ad", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15211,13 +15215,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/task.toml": "eac9dac0ceb32627a013c62b28a85077e8efef138eafb4f277d45e981c0438e7", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/task.toml": "0d4f62b420aafd8a78895f52bb04bd5dce9b04ec0b67893054a0a201ccbb34d3", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/tests/expected.json": "a7335aeb1e0930d6fdc78486f9473f76d1e0c3f1347ce0c36626bed6cebdf255", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/tests/scenario/episode.yaml": "55a5f26774fc6819b1e627b9c03a634cdd7f394dce6836db400434e240fb01ca", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/tests/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/tests/scenario/raw/lcbhard_1_oneoff_test.txt": "5497a5b8566ecad6d822784f9722ce1fcaba0faaf64d897827a07033f2752610", @@ -15240,14 +15244,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/docker-compose.yaml": "194f34881eccfea1fe2b4fd6385c658641d05ac81f1607a0b0593a2125a9500b", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/team/scenario/episode.yaml": "55a5f26774fc6819b1e627b9c03a634cdd7f394dce6836db400434e240fb01ca", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/team/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/team/scenario/raw/lcbhard_1_oneoff_test.txt": "5497a5b8566ecad6d822784f9722ce1fcaba0faaf64d897827a07033f2752610", @@ -15256,7 +15260,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/team/scenario/raw/lcbhard_1_rows.json": "007d9c1691d096b7b4d5fececaf9d6037ae0c9fd17fff842cf1fc953c738c3ce", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/team/scenario/record.json": "c4b761ea017764d08851353cb3e0ea3e99b7105857d78b0f3e54bf6bcada1b90", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/team/scenario/source.md": "a8842add47e71e2752e25264cc94be7ba67b70bf475e0219c285172729457d85", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/team/task.json": "b2837fdebeafafd5b53967e91514d75f01fb5094edc01207bbc6a6eafb5b9e3f", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/team/task.json": "84457547688999225a7c2843e789a1c944e0471a1a93ebfc0eb2e2d131ef6aa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15269,13 +15273,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/task.toml": "2cca4f15f7bbae9c44a19d39e837468487512e4b178444cc2a41a87769716273", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/task.toml": "5f291258fd171ef00cbae893b94968727fc9351cd1c85cebd8f39e7453612db8", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/tests/expected.json": "96c75d7cef29d28230e6ceda0fc8e6c36881485e89e90ae6354fb07722ee44b0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/tests/scenario/episode.yaml": "55a5f26774fc6819b1e627b9c03a634cdd7f394dce6836db400434e240fb01ca", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/tests/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/tests/scenario/raw/lcbhard_1_oneoff_test.txt": "5497a5b8566ecad6d822784f9722ce1fcaba0faaf64d897827a07033f2752610", @@ -15298,20 +15302,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/docker-compose.yaml": "c3056d67ff67607f5c55e950700a9d12e0a4528a2b6162e782d50ebc97a59503", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/team/scenario/episode.yaml": "c32e1468b1ee846800da9503bc65289ac5d4b185560ee910ab8456883b9780e9", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/team/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/team/scenario/prefill.json": "da4b51f0b25fc13f3e22fc3df7a17c5d20db00195e6bd42f0a1ce2c0667d5e58", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/team/scenario/record.json": "c4b761ea017764d08851353cb3e0ea3e99b7105857d78b0f3e54bf6bcada1b90", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/team/scenario/source.md": "a8842add47e71e2752e25264cc94be7ba67b70bf475e0219c285172729457d85", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/team/task.json": "f202b27f5b4a6bb6b7212bf8f0ff57cd1e2179cf5a6de7360b201a3ea37aafbd", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/team/task.json": "042045cea70696002e852e4726c4e40bf85cb91380fca76aa2e54e36502a1229", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15324,13 +15328,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/task.toml": "f65cf02994d80841c0828f0a9db41949f62b5e1900ca0e0732c024bf4298fb64", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/task.toml": "b6c6078349ab3ad5be634ea03837d2b74bbe90a1e5f171f5251ec724ced34770", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/tests/expected.json": "2955f92bd1428e77a8dec295f7aba5ed89ca374a62bbce3cedab3ef07837a3da", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/tests/scenario/episode.yaml": "c32e1468b1ee846800da9503bc65289ac5d4b185560ee910ab8456883b9780e9", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/tests/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/tests/scenario/prefill.json": "da4b51f0b25fc13f3e22fc3df7a17c5d20db00195e6bd42f0a1ce2c0667d5e58", @@ -15350,20 +15354,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/docker-compose.yaml": "558b816271f4218bee315a116f05a8f8aacf005565db443ca66e50f1e03ea2b0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/team/scenario/episode.yaml": "c32e1468b1ee846800da9503bc65289ac5d4b185560ee910ab8456883b9780e9", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/team/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/team/scenario/prefill.json": "da4b51f0b25fc13f3e22fc3df7a17c5d20db00195e6bd42f0a1ce2c0667d5e58", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/team/scenario/record.json": "c4b761ea017764d08851353cb3e0ea3e99b7105857d78b0f3e54bf6bcada1b90", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/team/scenario/source.md": "a8842add47e71e2752e25264cc94be7ba67b70bf475e0219c285172729457d85", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/team/task.json": "193b23d316d766be82135ba0500d735ad74963c9697bd04ab27f97cf3b9ac974", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/team/task.json": "d947345adcc03f1b002252169b8de2a51fcbc2828cf221035e9d86ba8b9605dd", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15376,13 +15380,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/task.toml": "a3cc196b4a5c87c44516d85704b8e185a74615a2797ae1a38319b96bad4a0cdb", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/task.toml": "ed70f355931b387993b7d08a1855a2b6af5879e4dc61e9487b1ffdf96fe418ef", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/tests/expected.json": "22c68a817773e6714ccc862930e57ec146403aba38885eb487fdd2c3738bc03a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/tests/scenario/episode.yaml": "c32e1468b1ee846800da9503bc65289ac5d4b185560ee910ab8456883b9780e9", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/tests/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/tests/scenario/prefill.json": "da4b51f0b25fc13f3e22fc3df7a17c5d20db00195e6bd42f0a1ce2c0667d5e58", @@ -15402,20 +15406,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/docker-compose.yaml": "aea0179747616fd1d6482965eb7e2cc1ec0e70377bd765527bb55c9981ab85eb", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/team/scenario/episode.yaml": "c32e1468b1ee846800da9503bc65289ac5d4b185560ee910ab8456883b9780e9", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/team/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/team/scenario/prefill.json": "da4b51f0b25fc13f3e22fc3df7a17c5d20db00195e6bd42f0a1ce2c0667d5e58", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/team/scenario/record.json": "c4b761ea017764d08851353cb3e0ea3e99b7105857d78b0f3e54bf6bcada1b90", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/team/scenario/source.md": "a8842add47e71e2752e25264cc94be7ba67b70bf475e0219c285172729457d85", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/team/task.json": "745f8cdb247c082d3839f66fece424af9b5d3e1649c87795b51858efbe91d0bb", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/team/task.json": "aa1d7d1bf95d9ad3811ce80f08023a0464bf21a95bab9d61f641713bd7854c82", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15428,13 +15432,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/task.toml": "3e165c319a7f832992f70b88adc15a89cf2c5f85ae72c901729df3d4afdef05e", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/task.toml": "f4262561ee325ac3ce50a2de39539f8ec93a293ee61fe2cadbbff7edca680fd2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/tests/expected.json": "176c0cd68ad61b6ae5c1c9a012669d3a479bf4cde172c5e972866b6178b2e44e", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/tests/scenario/episode.yaml": "c32e1468b1ee846800da9503bc65289ac5d4b185560ee910ab8456883b9780e9", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/tests/scenario/notes.md": "447d79aa6dbdfe1962fcc67d5e2887cb21cd7303aeb515c219a2881ace9dc8b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/tests/scenario/prefill.json": "da4b51f0b25fc13f3e22fc3df7a17c5d20db00195e6bd42f0a1ce2c0667d5e58", @@ -15454,14 +15458,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/docker-compose.yaml": "4b5038c5fc638ed2adebcac6026e6605df0da5c3db8abeaf2c9c9663d6f52588", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/team/scenario/episode.yaml": "c2d42858409dfa75a5b223a34a0628332197c32ebd3fa0fca9b7abcddd876d24", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/team/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/team/scenario/raw/lcbhard_28_oneoff_test.txt": "0b7833b162ca69887d179be78d752e083d411b9070ce3234c15e96218d90fa7c", @@ -15470,7 +15474,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/team/scenario/raw/lcbhard_28_rows.json": "d7ce64bfaeacfb551b057c24d7cfc84c597ac90962564bca0138b7bceedd217a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/team/scenario/record.json": "ee12d612c2db190b0e1df262b385e5b9bc3f1d677a592ee5b33105d128332c21", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/team/scenario/source.md": "8610f21b0298033e1fa64731ffcebbf200e1251af88b2a5709b6b1c7a866590f", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/team/task.json": "2baf24e8703a0f38ff20cf43e43342efd0d34a1b812a7053df3e9eceebb4d84b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/team/task.json": "88cd4dee72207bd53e8f7307a00af75d35118eaa75ce38cbae8cdb6fd1bd12e9", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15483,13 +15487,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/task.toml": "d518bec381482d31801991cd1517d9730ff7859016dc0a6d22b0b393c873424f", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/task.toml": "77516f1793a95087d5b0455e62cfc30dae9f7909baa72b5fba308485a2b0ab39", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/tests/expected.json": "0239e8678bd498e14d72f54bd2ba89c349cf51ddfe7ee37a93dc31da82b6e6e3", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/tests/scenario/episode.yaml": "c2d42858409dfa75a5b223a34a0628332197c32ebd3fa0fca9b7abcddd876d24", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/tests/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/tests/scenario/raw/lcbhard_28_oneoff_test.txt": "0b7833b162ca69887d179be78d752e083d411b9070ce3234c15e96218d90fa7c", @@ -15512,14 +15516,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/docker-compose.yaml": "cd726ab003f203903fcfad15a6e9cf9f01a94d4fd5693aef6e69f3b992925c42", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/team/scenario/episode.yaml": "c2d42858409dfa75a5b223a34a0628332197c32ebd3fa0fca9b7abcddd876d24", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/team/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/team/scenario/raw/lcbhard_28_oneoff_test.txt": "0b7833b162ca69887d179be78d752e083d411b9070ce3234c15e96218d90fa7c", @@ -15528,7 +15532,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/team/scenario/raw/lcbhard_28_rows.json": "d7ce64bfaeacfb551b057c24d7cfc84c597ac90962564bca0138b7bceedd217a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/team/scenario/record.json": "ee12d612c2db190b0e1df262b385e5b9bc3f1d677a592ee5b33105d128332c21", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/team/scenario/source.md": "8610f21b0298033e1fa64731ffcebbf200e1251af88b2a5709b6b1c7a866590f", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/team/task.json": "d1761f722be7226878a072e8df4af17534dfcc6feec1c1251ed8b3ebb3908bb7", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/team/task.json": "b7e817f7d55bd4e8f636d6aa58e8f9591fdce15ef565ae076c0d614d734f1c81", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15541,13 +15545,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/task.toml": "f12e1f0cb90b119757ce572ab7224354ffd2de5e57aab4ed49dfb79d5dd6ca9a", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/task.toml": "b46ae5b5979f1de8932937878a34a8e52934e2831abc71ab0fd3850d2fabdfbb", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/tests/expected.json": "c72f649c433f4d06891cc20c46bfb07c3fd7abcfef6923a3be8966831f64eece", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/tests/scenario/episode.yaml": "c2d42858409dfa75a5b223a34a0628332197c32ebd3fa0fca9b7abcddd876d24", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/tests/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/tests/scenario/raw/lcbhard_28_oneoff_test.txt": "0b7833b162ca69887d179be78d752e083d411b9070ce3234c15e96218d90fa7c", @@ -15570,20 +15574,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/docker-compose.yaml": "c43ea9eca032ec4e6a4fe4e1f08ac6d7d1691326982f700a05b2df19035b5aa2", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/team/scenario/episode.yaml": "928ac1d010e1f5ea103cdf31dc29a0ca3e898d35308ed43d763196184c43e77f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/team/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/team/scenario/prefill.json": "a2d5d4ec27c4eef09d5ba11716ef185bd368c4b35bc6dbcb03af3cbe0360f03b", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/team/scenario/record.json": "ee12d612c2db190b0e1df262b385e5b9bc3f1d677a592ee5b33105d128332c21", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/team/scenario/source.md": "8610f21b0298033e1fa64731ffcebbf200e1251af88b2a5709b6b1c7a866590f", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/team/task.json": "3a7932ec33bf9cae51db4c4c08c7881da3b93f0c68911b9655c9180a11132265", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/team/task.json": "b17a1156c4abe0c70a8d955d972991feb0ad355c3f6241c03ec2de41b2c05e8a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15596,13 +15600,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/task.toml": "0730b321dd68d42675560c48230d04fa9f668dc505f1c64d1a1e6f88130f0b6b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/task.toml": "5aea7746b7adfcb9bd561386be212eb92928d58e9ab32f730d9764b449820d5c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/tests/expected.json": "49e41226b677d18ca2e6abc7c4bf7f2d57688d88c27f8ed0dfab48d2bb4639a0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/tests/scenario/episode.yaml": "928ac1d010e1f5ea103cdf31dc29a0ca3e898d35308ed43d763196184c43e77f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/tests/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/tests/scenario/prefill.json": "a2d5d4ec27c4eef09d5ba11716ef185bd368c4b35bc6dbcb03af3cbe0360f03b", @@ -15622,20 +15626,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/docker-compose.yaml": "4e6c2b5f4e8ab6d19ba1c98a632733891c884e35e9b5d4e128fa7618e2dc4fc8", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/team/scenario/episode.yaml": "928ac1d010e1f5ea103cdf31dc29a0ca3e898d35308ed43d763196184c43e77f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/team/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/team/scenario/prefill.json": "a2d5d4ec27c4eef09d5ba11716ef185bd368c4b35bc6dbcb03af3cbe0360f03b", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/team/scenario/record.json": "ee12d612c2db190b0e1df262b385e5b9bc3f1d677a592ee5b33105d128332c21", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/team/scenario/source.md": "8610f21b0298033e1fa64731ffcebbf200e1251af88b2a5709b6b1c7a866590f", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/team/task.json": "10eb716c8003d7b7af48c03e190e6d31666f7376634dc38fd7bf99e2a44a85f5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/team/task.json": "ced361b04ebd85254841af8231226f14ea7583e27487841a4964153565d7047b", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15648,13 +15652,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/task.toml": "13147b9a7b3f08f4ba21b9ae01c80c5530a1ca9eee114e01efc9e28dafb1ea26", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/task.toml": "c6f1ecf2fe46e159074ea1eabb992c50c66eb5b6cd663e3df4d858aaac97d905", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/tests/expected.json": "8345a13be4c300169bc50952cc45bb97a96a1546b0a38fddce2e42c7121bcf69", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/tests/scenario/episode.yaml": "928ac1d010e1f5ea103cdf31dc29a0ca3e898d35308ed43d763196184c43e77f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/tests/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/tests/scenario/prefill.json": "a2d5d4ec27c4eef09d5ba11716ef185bd368c4b35bc6dbcb03af3cbe0360f03b", @@ -15674,20 +15678,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/docker-compose.yaml": "6186411fbf3fb17a3a2527eb02919ab1d45db1c5cda0ae14c8ac2fd36b44448d", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/team/scenario/episode.yaml": "928ac1d010e1f5ea103cdf31dc29a0ca3e898d35308ed43d763196184c43e77f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/team/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/team/scenario/prefill.json": "a2d5d4ec27c4eef09d5ba11716ef185bd368c4b35bc6dbcb03af3cbe0360f03b", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/team/scenario/record.json": "ee12d612c2db190b0e1df262b385e5b9bc3f1d677a592ee5b33105d128332c21", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/team/scenario/source.md": "8610f21b0298033e1fa64731ffcebbf200e1251af88b2a5709b6b1c7a866590f", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/team/task.json": "7896449f943da9164a3e93417ba8c49388c4831b0cfd1d27d37fbfda8eea5972", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/team/task.json": "24793d758787d8856e1c0cbe8883bdaf09950b8df42eefdf7363440c07587ec4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15700,13 +15704,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/task.toml": "11c48a53ebc9d666b8e1c8f0cbc18f1d18a15a47c9b3c63bd7b0bbadee0e43a8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/task.toml": "e83a0815e26acca5d3148cf53599695d382ed739bd54de03381da9df10394b01", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/tests/expected.json": "3ba072e666ef31767866c2af252dbadedd85f097fe3971ea6930cabcccd100f3", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/tests/scenario/episode.yaml": "928ac1d010e1f5ea103cdf31dc29a0ca3e898d35308ed43d763196184c43e77f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/tests/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/tests/scenario/prefill.json": "a2d5d4ec27c4eef09d5ba11716ef185bd368c4b35bc6dbcb03af3cbe0360f03b", @@ -15726,14 +15730,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/docker-compose.yaml": "dbcbcc51f1f45bc7de52d626b0c1bf400317d114a45ab9f7f2e4cd01b27ca823", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/team/scenario/episode.yaml": "c2d42858409dfa75a5b223a34a0628332197c32ebd3fa0fca9b7abcddd876d24", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/team/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/team/scenario/raw/lcbhard_28_oneoff_test.txt": "0b7833b162ca69887d179be78d752e083d411b9070ce3234c15e96218d90fa7c", @@ -15742,7 +15746,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/team/scenario/raw/lcbhard_28_rows.json": "d7ce64bfaeacfb551b057c24d7cfc84c597ac90962564bca0138b7bceedd217a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/team/scenario/record.json": "ee12d612c2db190b0e1df262b385e5b9bc3f1d677a592ee5b33105d128332c21", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/team/scenario/source.md": "8610f21b0298033e1fa64731ffcebbf200e1251af88b2a5709b6b1c7a866590f", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/team/task.json": "effe502b139af332cc686e20e77480a13493b017e1cf29e55fb0ad0d3d8a1d64", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/team/task.json": "5f8a73cafbdf16198754f15c82286d59882bbe852705731ef0d74040ca505a43", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15755,13 +15759,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/task.toml": "94e1580f889f46f6f9b2f8ed5aceac5bbe5df7cf3e064be2f419e15903b563c6", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/task.toml": "1af15215df787801b36e0d215656d87e5dfa378de7c24192e58a5686afc3ee55", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/tests/expected.json": "413c3d6bc158c497a0c6e0e1f0cba1e97a77ca3d6d959fec5e78dd66b0af5259", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/tests/scenario/episode.yaml": "c2d42858409dfa75a5b223a34a0628332197c32ebd3fa0fca9b7abcddd876d24", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/tests/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/tests/scenario/raw/lcbhard_28_oneoff_test.txt": "0b7833b162ca69887d179be78d752e083d411b9070ce3234c15e96218d90fa7c", @@ -15784,14 +15788,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/docker-compose.yaml": "8787300bb212383eec3e5b861047f2a46e4192f6aad245348bae8964f907f32d", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/team/scenario/episode.yaml": "c2d42858409dfa75a5b223a34a0628332197c32ebd3fa0fca9b7abcddd876d24", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/team/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/team/scenario/raw/lcbhard_28_oneoff_test.txt": "0b7833b162ca69887d179be78d752e083d411b9070ce3234c15e96218d90fa7c", @@ -15800,7 +15804,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/team/scenario/raw/lcbhard_28_rows.json": "d7ce64bfaeacfb551b057c24d7cfc84c597ac90962564bca0138b7bceedd217a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/team/scenario/record.json": "ee12d612c2db190b0e1df262b385e5b9bc3f1d677a592ee5b33105d128332c21", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/team/scenario/source.md": "8610f21b0298033e1fa64731ffcebbf200e1251af88b2a5709b6b1c7a866590f", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/team/task.json": "88ace80b8345632e9cc952fe221a4ed29f8f9da442ad4f635725610857d40e2d", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/team/task.json": "b8250da335a29f8055b3b7a3dd691d597c2613bb609a478bbca7020147bef659", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15813,13 +15817,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/task.toml": "72f11cfa7d293a872fd61d623f67406c4086bad9aac82cb6dc4ce4214f105d96", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/task.toml": "a020b81d3a0eec46489d9cd5b6236348c694f2c49b5c74f2d0897bfe2c0db952", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/tests/expected.json": "47e7221d942f733b00b3cac614f41567eb8432332f88bcb4e6915a1459dcc989", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/tests/scenario/episode.yaml": "c2d42858409dfa75a5b223a34a0628332197c32ebd3fa0fca9b7abcddd876d24", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/tests/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/tests/scenario/raw/lcbhard_28_oneoff_test.txt": "0b7833b162ca69887d179be78d752e083d411b9070ce3234c15e96218d90fa7c", @@ -15842,20 +15846,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/docker-compose.yaml": "26e492f2e24c6a03269df670408e1666f0d1a10d99398261bae4b3217b9d7d2d", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/team/scenario/episode.yaml": "d4630997fac6edb626d8af0288a16bdab94603ba1ac1af050e41dbd8883c5ab0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/team/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/team/scenario/prefill.json": "314cacc9b3597c54067682fb43e56c9a360e219c1b8c7ad18aa7deda2280781e", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/team/scenario/record.json": "ee12d612c2db190b0e1df262b385e5b9bc3f1d677a592ee5b33105d128332c21", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/team/scenario/source.md": "8610f21b0298033e1fa64731ffcebbf200e1251af88b2a5709b6b1c7a866590f", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/team/task.json": "a3689205b0f02449d54ae94838fce703d6ba61ab408af1353e91b83b8de62525", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/team/task.json": "15c127eb5600b5810286e08364c26b9a134d4f76371d8a7d354a37a3a4140671", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15868,13 +15872,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/task.toml": "e4175aff8316c08bcdf56acb9bacff8165dc0e53027e40c028ae50ca1c3d7c92", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/task.toml": "cb2357dbeceef3d35b53051afa42337e34d0550d51f257ab4c470011f2b38f4e", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/tests/expected.json": "561e170868c343896c97368b3f1a1ae2ad5cc6136ff50b3fc860487fdd327322", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/tests/scenario/episode.yaml": "d4630997fac6edb626d8af0288a16bdab94603ba1ac1af050e41dbd8883c5ab0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/tests/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/tests/scenario/prefill.json": "314cacc9b3597c54067682fb43e56c9a360e219c1b8c7ad18aa7deda2280781e", @@ -15894,20 +15898,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/docker-compose.yaml": "b8cacc50663b5e215975d034dfa6a08b3cb6dba2016039b1c4b51cdb31eab232", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/team/scenario/episode.yaml": "d4630997fac6edb626d8af0288a16bdab94603ba1ac1af050e41dbd8883c5ab0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/team/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/team/scenario/prefill.json": "314cacc9b3597c54067682fb43e56c9a360e219c1b8c7ad18aa7deda2280781e", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/team/scenario/record.json": "ee12d612c2db190b0e1df262b385e5b9bc3f1d677a592ee5b33105d128332c21", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/team/scenario/source.md": "8610f21b0298033e1fa64731ffcebbf200e1251af88b2a5709b6b1c7a866590f", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/team/task.json": "b571269d9c2252fe301df86b65d7dfc739b4d2d5fb68c7361f61ef7f8599347a", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/team/task.json": "c58cd2c1da3c6727ee4ab543e4d39e703b791e3eac190679754e1e43acafa630", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15920,13 +15924,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/task.toml": "c429e78fc62365ed066787822b711cce78ba953b9b842b65f90f95a453a33ff3", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/task.toml": "3b37b2c1c28f502225683910b8a06a2b3d173923c7d23041a80cc0baec0c1a45", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/tests/expected.json": "6a47596df0d0129a0ce8e9225b72dc66a9529a1ba2f5d962a358bc75a60df0e6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/tests/scenario/episode.yaml": "d4630997fac6edb626d8af0288a16bdab94603ba1ac1af050e41dbd8883c5ab0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/tests/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/tests/scenario/prefill.json": "314cacc9b3597c54067682fb43e56c9a360e219c1b8c7ad18aa7deda2280781e", @@ -15946,20 +15950,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/docker-compose.yaml": "9263fb48b72655d71faca4d28ce77b4dd5b27347080e8a8c0cdcae98cba4b721", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/team/scenario/episode.yaml": "d4630997fac6edb626d8af0288a16bdab94603ba1ac1af050e41dbd8883c5ab0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/team/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/team/scenario/prefill.json": "314cacc9b3597c54067682fb43e56c9a360e219c1b8c7ad18aa7deda2280781e", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/team/scenario/record.json": "ee12d612c2db190b0e1df262b385e5b9bc3f1d677a592ee5b33105d128332c21", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/team/scenario/source.md": "8610f21b0298033e1fa64731ffcebbf200e1251af88b2a5709b6b1c7a866590f", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/team/task.json": "f19cfc05cf0c18d43bea5d273c4ebe173ca92f73ee67cdd794e8138a77a58d23", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/team/task.json": "75b55214b2ac4c6a1e5b11e09720f9c4073f565e1f501c6ba53e732d9b3f9862", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -15972,13 +15976,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/task.toml": "2867c492a3b120bab96f0c0383b7bcf61037a0225f238cc52518a32d74168703", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/task.toml": "020cc955fdba288d8bace88895f4c8bbd0e30ad3a64a17931cff83ea36649d5a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/tests/expected.json": "1aeade1d36f946f48b6f9091a382e13d061944acf3d614b550ff7a59a24186db", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/tests/scenario/episode.yaml": "d4630997fac6edb626d8af0288a16bdab94603ba1ac1af050e41dbd8883c5ab0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/tests/scenario/notes.md": "5c66a0280665b71b4aecc26a6a5b5e9330708ea8d1a353346e6e23d60d79783f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/tests/scenario/prefill.json": "314cacc9b3597c54067682fb43e56c9a360e219c1b8c7ad18aa7deda2280781e", @@ -15998,14 +16002,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/docker-compose.yaml": "decdf339c3e89a1d408457892329f5748a7fa118126273411be1cb933de4d09c", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/team/scenario/episode.yaml": "b52c4c72930eee8d6df22ffce608db3f2300970bc75ac109ad08928413fa7958", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/team/scenario/notes.md": "10e7f5d38ddbe3e49ed93a58bd6403abe8b550821a21b7677fca3ed0a7f8d70c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/team/scenario/raw/lcbhard_29_oneoff_test.txt": "a62bfccfd98a46ff79eaed12192a570b098683e7d331a430ef16d26d40a941ea", @@ -16014,7 +16018,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/team/scenario/raw/lcbhard_29_rows.json": "87f3e1aab2452674e6c0716a9a2dcac8d93b3d3fd6a14bc0caa794237f96d874", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/team/scenario/record.json": "039f52eaab9b1fa3f56b81edda576a0d7c9e94ce0a18abb60c2c27ec95d0a70c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/team/scenario/source.md": "68bd04ee1180ed7ae3ca9bfd414506cbbb657b0a927aca16d26a3f0f984712c6", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/team/task.json": "f3e5929e4e70f31363f19a8880788f1996f34fdc6592ff6cd6964207f3a00a07", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/team/task.json": "760ef4051fb0568720530708af206d5cf8e95ec14e539e92e14b4406c0a35600", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16027,13 +16031,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/task.toml": "25bd78f42aa99c8205b9be02632cf828c8446a851ed57fce590cc8ca481a3b0d", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/task.toml": "77597c0240440494153a47fc63bd584377338a89d22d94eb62c72594d05b535c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/tests/expected.json": "1d7fa73ff8734bec855884ca213bcfbc2802ce149bf945a0771a15e9681f4df0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/tests/scenario/episode.yaml": "b52c4c72930eee8d6df22ffce608db3f2300970bc75ac109ad08928413fa7958", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/tests/scenario/notes.md": "10e7f5d38ddbe3e49ed93a58bd6403abe8b550821a21b7677fca3ed0a7f8d70c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/tests/scenario/raw/lcbhard_29_oneoff_test.txt": "a62bfccfd98a46ff79eaed12192a570b098683e7d331a430ef16d26d40a941ea", @@ -16056,14 +16060,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/docker-compose.yaml": "a27be4adc854d5bbb031f7c9366b1382d29b05359fbe9059fe8acd6754ddefcc", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/team/scenario/episode.yaml": "b52c4c72930eee8d6df22ffce608db3f2300970bc75ac109ad08928413fa7958", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/team/scenario/notes.md": "10e7f5d38ddbe3e49ed93a58bd6403abe8b550821a21b7677fca3ed0a7f8d70c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/team/scenario/raw/lcbhard_29_oneoff_test.txt": "a62bfccfd98a46ff79eaed12192a570b098683e7d331a430ef16d26d40a941ea", @@ -16072,7 +16076,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/team/scenario/raw/lcbhard_29_rows.json": "87f3e1aab2452674e6c0716a9a2dcac8d93b3d3fd6a14bc0caa794237f96d874", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/team/scenario/record.json": "039f52eaab9b1fa3f56b81edda576a0d7c9e94ce0a18abb60c2c27ec95d0a70c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/team/scenario/source.md": "68bd04ee1180ed7ae3ca9bfd414506cbbb657b0a927aca16d26a3f0f984712c6", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/team/task.json": "eb7dc0ed2a95bb35988561999b89226cb987ca4576986e2edf23dd48a185dd52", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/team/task.json": "267a0e82f422464f0203cb2844fe393c92da907b1a5defc603237d74884ea672", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16085,13 +16089,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/task.toml": "fb9c13e15681880c5d476718249c4618a5a1223e92d173f8b068bf38011685ce", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/task.toml": "b09980df3f4c161ed92ec65973c4bd9bc67910430b45a435ecf0556bf847e40e", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/tests/expected.json": "120e8582a4836aa9b4d0f261a40a9a788526453f4f4062c55b244311602b6d6e", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/tests/scenario/episode.yaml": "b52c4c72930eee8d6df22ffce608db3f2300970bc75ac109ad08928413fa7958", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/tests/scenario/notes.md": "10e7f5d38ddbe3e49ed93a58bd6403abe8b550821a21b7677fca3ed0a7f8d70c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/tests/scenario/raw/lcbhard_29_oneoff_test.txt": "a62bfccfd98a46ff79eaed12192a570b098683e7d331a430ef16d26d40a941ea", @@ -16114,20 +16118,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/docker-compose.yaml": "ca3386801ff3f06a6ffa419b97cd5b76b2f0cbc8cf9b0e7baf2eb21580f51a07", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/team/scenario/episode.yaml": "5e8d92d6805b0138babbc44355089054de5408765d7d7fc05a8e750f606098bd", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/team/scenario/notes.md": "10e7f5d38ddbe3e49ed93a58bd6403abe8b550821a21b7677fca3ed0a7f8d70c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/team/scenario/prefill.json": "262a652137cefffed4a5054820a77c63535efcd0776aae218b638e30544b05d5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/team/scenario/record.json": "039f52eaab9b1fa3f56b81edda576a0d7c9e94ce0a18abb60c2c27ec95d0a70c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/team/scenario/source.md": "68bd04ee1180ed7ae3ca9bfd414506cbbb657b0a927aca16d26a3f0f984712c6", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/team/task.json": "45267e2662a38aad96b66a3a17a80696cc0861c194f0703350ef429cc112bf22", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/team/task.json": "dacf1a0b70ff035b4233a8c3b21ca9a622a27c1e436e77a453a0eada7b83bc21", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16140,13 +16144,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/task.toml": "6ef8871c6b22bca3d617ad958b04526a6b6a76476eb4a97530ae106f466c0416", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/task.toml": "92f1c517f9c97b840ed907491b94512ad7d7d5939612d57998d8174b8d42ba2b", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/tests/expected.json": "df0f96d8a4e320ff0ef5646f047a3f24fddef491f6e0fe7d6e41f9f88ea41ff6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/tests/scenario/episode.yaml": "5e8d92d6805b0138babbc44355089054de5408765d7d7fc05a8e750f606098bd", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/tests/scenario/notes.md": "10e7f5d38ddbe3e49ed93a58bd6403abe8b550821a21b7677fca3ed0a7f8d70c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/tests/scenario/prefill.json": "262a652137cefffed4a5054820a77c63535efcd0776aae218b638e30544b05d5", @@ -16166,20 +16170,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/docker-compose.yaml": "8825bf5ee825a94289f06d72deb1f9bc6c56532b44ef28dadf779bdf8d3222e1", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/team/scenario/episode.yaml": "5e8d92d6805b0138babbc44355089054de5408765d7d7fc05a8e750f606098bd", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/team/scenario/notes.md": "10e7f5d38ddbe3e49ed93a58bd6403abe8b550821a21b7677fca3ed0a7f8d70c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/team/scenario/prefill.json": "262a652137cefffed4a5054820a77c63535efcd0776aae218b638e30544b05d5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/team/scenario/record.json": "039f52eaab9b1fa3f56b81edda576a0d7c9e94ce0a18abb60c2c27ec95d0a70c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/team/scenario/source.md": "68bd04ee1180ed7ae3ca9bfd414506cbbb657b0a927aca16d26a3f0f984712c6", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/team/task.json": "421bee55e062f74bcdb97b96dd9ebdb957347508faec61e7efebc00bdcf68a17", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/team/task.json": "8caf6a42170317d1d5baae8f5ab5438a91ac1ebb24a6b14be4d82359a028123a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16192,13 +16196,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/task.toml": "6189f56926d000c3863c1f6e72857219824b60dbc0d52a10e27ec3cd45c52034", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/task.toml": "787f22419d8294429b4809059cb4790ae4c6920b395bc7b61378b2afe2962d2c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/tests/expected.json": "97083a3a4fcbaa9242a8209534033639f054e90d86951be8b8c39a3ad2741e81", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/tests/scenario/episode.yaml": "5e8d92d6805b0138babbc44355089054de5408765d7d7fc05a8e750f606098bd", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/tests/scenario/notes.md": "10e7f5d38ddbe3e49ed93a58bd6403abe8b550821a21b7677fca3ed0a7f8d70c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/tests/scenario/prefill.json": "262a652137cefffed4a5054820a77c63535efcd0776aae218b638e30544b05d5", @@ -16218,20 +16222,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/docker-compose.yaml": "6666d768bfa6459b475d3a430038638e87b162d2b16a93c852b4b090f8f80540", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/team/scenario/episode.yaml": "5e8d92d6805b0138babbc44355089054de5408765d7d7fc05a8e750f606098bd", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/team/scenario/notes.md": "10e7f5d38ddbe3e49ed93a58bd6403abe8b550821a21b7677fca3ed0a7f8d70c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/team/scenario/prefill.json": "262a652137cefffed4a5054820a77c63535efcd0776aae218b638e30544b05d5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/team/scenario/record.json": "039f52eaab9b1fa3f56b81edda576a0d7c9e94ce0a18abb60c2c27ec95d0a70c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/team/scenario/source.md": "68bd04ee1180ed7ae3ca9bfd414506cbbb657b0a927aca16d26a3f0f984712c6", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/team/task.json": "c1c4ffd210236fb387c8e0f400aafa72abd937e9f20f0d03f8f2a8779414c6bb", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/team/task.json": "33cc7205f958ebcaab55089e07d3d4aea197176a309063f01e5132a250ed0521", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16244,13 +16248,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/task.toml": "1ea4fc6858f3260d476c5f87cd7a7c00fb3323053c0fbf28cb62814f5807634a", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/task.toml": "046d0f168ad6733f4e4abc84d903e8844229b827c0d670bb8fa74cddcb6f16e8", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/tests/expected.json": "9545c92f4ed30967d6e945e8e7e8752b26fdefd1dc4455a57d48d5e40a5f33df", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/tests/scenario/episode.yaml": "5e8d92d6805b0138babbc44355089054de5408765d7d7fc05a8e750f606098bd", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/tests/scenario/notes.md": "10e7f5d38ddbe3e49ed93a58bd6403abe8b550821a21b7677fca3ed0a7f8d70c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/tests/scenario/prefill.json": "262a652137cefffed4a5054820a77c63535efcd0776aae218b638e30544b05d5", @@ -16270,14 +16274,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/docker-compose.yaml": "960449e8e0c065001b91690df328d4bd9319195e41ed29cc882400eee96bcc6c", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/team/scenario/episode.yaml": "d1efdcf9156a8e3fd600b667bd330298b12bf05650357bfabdb6ecaa9767053f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/team/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/team/scenario/raw/lcbhard_3_oneoff_test.txt": "f600ec6338b2f9ab069eb5f1823e1837a19c1794423a03ee7b48fcaa8919e1d7", @@ -16286,7 +16290,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/team/scenario/raw/lcbhard_3_rows.json": "373b9802e1b13b0723183df699d11d409d92e3ae5d9fade4ef0d566aa7241d3a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/team/scenario/record.json": "31a166abe3dab04e04bd3bba58c683579fe5c53c72e5f6f08bbb92b29a36546f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/team/scenario/source.md": "0cb1438ca9a9a026b8ae7be4119b68d4a13abcc59b3ae9c2f5ca1eb87c64833e", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/team/task.json": "5a6e0cc33cbdcfe2adeadb57498bf782ae117f598d16712512d1913d5dea54b4", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/team/task.json": "7b86979cd6b2155092c68c9f110c7e21a537abec9c4131a6218a4624b3e5f2f9", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16299,13 +16303,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/task.toml": "a2e6b32fb3f8829ad76063e1eba5ef9c8e8be5ac889f52d57231bd295462525c", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/task.toml": "ec7fbcf69d866001de8a4c339a7a5dee467861d9b8acc14a1b51acd6befc164f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/tests/expected.json": "f5ea8c19a494cc6cd5abaad6e9e338b1c49661fabc770b6336633f432ce7aedb", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/tests/scenario/episode.yaml": "d1efdcf9156a8e3fd600b667bd330298b12bf05650357bfabdb6ecaa9767053f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/tests/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/tests/scenario/raw/lcbhard_3_oneoff_test.txt": "f600ec6338b2f9ab069eb5f1823e1837a19c1794423a03ee7b48fcaa8919e1d7", @@ -16328,14 +16332,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/docker-compose.yaml": "a1e6e00e74544a756fef27d16930a99d8a6ad038ccae6cafcb45732e765264e4", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/team/scenario/episode.yaml": "d1efdcf9156a8e3fd600b667bd330298b12bf05650357bfabdb6ecaa9767053f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/team/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/team/scenario/raw/lcbhard_3_oneoff_test.txt": "f600ec6338b2f9ab069eb5f1823e1837a19c1794423a03ee7b48fcaa8919e1d7", @@ -16344,7 +16348,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/team/scenario/raw/lcbhard_3_rows.json": "373b9802e1b13b0723183df699d11d409d92e3ae5d9fade4ef0d566aa7241d3a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/team/scenario/record.json": "31a166abe3dab04e04bd3bba58c683579fe5c53c72e5f6f08bbb92b29a36546f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/team/scenario/source.md": "0cb1438ca9a9a026b8ae7be4119b68d4a13abcc59b3ae9c2f5ca1eb87c64833e", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/team/task.json": "09bb1d9c6b6934840fce679a5723efb5bfb770074f6d6cc628aa63e77c6b85d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/team/task.json": "d74e90364d096ac38030c953f6125194dc0b9666d95b4b1a9cf786125486d136", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16357,13 +16361,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/task.toml": "8b484336f4412b6290033610d5f556367f60bf3378d759414d8560a6bb298689", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/task.toml": "7dd1b3e67ff5762ce4ba00e5fd385549e2d4027fee16608b10aed1eaf06ac3d1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/tests/expected.json": "4ccb3b321393c62cf5c36aedad395b18847a61d2f150235a4c3922bdd9146377", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/tests/scenario/episode.yaml": "d1efdcf9156a8e3fd600b667bd330298b12bf05650357bfabdb6ecaa9767053f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/tests/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/tests/scenario/raw/lcbhard_3_oneoff_test.txt": "f600ec6338b2f9ab069eb5f1823e1837a19c1794423a03ee7b48fcaa8919e1d7", @@ -16386,20 +16390,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/docker-compose.yaml": "a063d8ada4d4d2ad5fc1808735614360767259e2583a12a044368bd00ad21cbb", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/team/scenario/episode.yaml": "61302c17ce2438d8993cb1e4ca223bc1f37dcd8c9d0594dc5541bf5323397c8c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/team/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/team/scenario/prefill.json": "79541b0f4beeb97f4edd1e8c1fb0d228564c2063576cedf37c37a70e883e55e4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/team/scenario/record.json": "31a166abe3dab04e04bd3bba58c683579fe5c53c72e5f6f08bbb92b29a36546f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/team/scenario/source.md": "0cb1438ca9a9a026b8ae7be4119b68d4a13abcc59b3ae9c2f5ca1eb87c64833e", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/team/task.json": "40547d5efa90ea636ae1298cf98984d3269d0ba4cd894de526011a5bf4701406", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/team/task.json": "7a3e2fc83299db1d87563d833b46cc1fc7b00034997491db31f0d468487ae288", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16412,13 +16416,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/task.toml": "d602bbeef5404a9440d13e1f19f22879c12cd16d18af2860783df28e65ccf2c2", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/task.toml": "c2db5dcc5b0acd16deb54d2185464c14592b9be6d7e92c69796e5c3b098adfa5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/tests/expected.json": "602e8e1e2ad6c920485a17638a5444d809360171573a7bd9445995a99526e91d", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/tests/scenario/episode.yaml": "61302c17ce2438d8993cb1e4ca223bc1f37dcd8c9d0594dc5541bf5323397c8c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/tests/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/tests/scenario/prefill.json": "79541b0f4beeb97f4edd1e8c1fb0d228564c2063576cedf37c37a70e883e55e4", @@ -16438,20 +16442,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/docker-compose.yaml": "dab6ab11877b3bd0057daa8ae03f6e7194af41eed0c2d70d9d64293c35823829", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/team/scenario/episode.yaml": "61302c17ce2438d8993cb1e4ca223bc1f37dcd8c9d0594dc5541bf5323397c8c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/team/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/team/scenario/prefill.json": "79541b0f4beeb97f4edd1e8c1fb0d228564c2063576cedf37c37a70e883e55e4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/team/scenario/record.json": "31a166abe3dab04e04bd3bba58c683579fe5c53c72e5f6f08bbb92b29a36546f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/team/scenario/source.md": "0cb1438ca9a9a026b8ae7be4119b68d4a13abcc59b3ae9c2f5ca1eb87c64833e", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/team/task.json": "b17500f4b9135cb88857f62365d28ecc6d3d419259f985519269139ab197d1b3", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/team/task.json": "56572f162211f537239acd1ee4dcfd306e200412e69e84f39b60a19216cdb97b", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16464,13 +16468,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/task.toml": "254856e2883e167ce75d5b1021bfc83e1eee8bec4db64fdbbf4a94ea819a6445", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/task.toml": "dded428fa6eeb0a8b0eb5e5ee720cb262f0bd6369221497670bf390a70f515ae", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/tests/expected.json": "2102c1c2750234b490b20daef8d9a48e65aef6b5d45219288dc066cb4fc686ba", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/tests/scenario/episode.yaml": "61302c17ce2438d8993cb1e4ca223bc1f37dcd8c9d0594dc5541bf5323397c8c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/tests/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/tests/scenario/prefill.json": "79541b0f4beeb97f4edd1e8c1fb0d228564c2063576cedf37c37a70e883e55e4", @@ -16490,20 +16494,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/docker-compose.yaml": "3837fc6c045a44ab4aee934d768dfa568878a62266e4a0a907c0017d58fbb0e5", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/team/scenario/episode.yaml": "61302c17ce2438d8993cb1e4ca223bc1f37dcd8c9d0594dc5541bf5323397c8c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/team/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/team/scenario/prefill.json": "79541b0f4beeb97f4edd1e8c1fb0d228564c2063576cedf37c37a70e883e55e4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/team/scenario/record.json": "31a166abe3dab04e04bd3bba58c683579fe5c53c72e5f6f08bbb92b29a36546f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/team/scenario/source.md": "0cb1438ca9a9a026b8ae7be4119b68d4a13abcc59b3ae9c2f5ca1eb87c64833e", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/team/task.json": "02b7d94bf53b760068e9cd794be7d40505df5004baa26dc5a6fa6f9957e8ebb0", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/team/task.json": "c79986bb5e21a3fc6100b8879f24169710455e2a386022ffdecad48f56a2c506", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16516,13 +16520,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/task.toml": "a959388f7beb247dac3d0bffa92e94da520350e9d72e3d29128b8327f5b94f9c", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/task.toml": "dda2f7309a2da58f83ce570b2169097e30aaff9b0db06a2813bf93c84d4d8571", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/tests/expected.json": "5f2335740e2b9e955fd9d527bc509c98181b72eaf40371a7197161c1d7f30ae1", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/tests/scenario/episode.yaml": "61302c17ce2438d8993cb1e4ca223bc1f37dcd8c9d0594dc5541bf5323397c8c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/tests/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/tests/scenario/prefill.json": "79541b0f4beeb97f4edd1e8c1fb0d228564c2063576cedf37c37a70e883e55e4", @@ -16542,14 +16546,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/docker-compose.yaml": "3e6d4d4d81b8e5133e9ba9d6934e478303041ad41e871283347c896ea4398aa9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/team/scenario/episode.yaml": "d1efdcf9156a8e3fd600b667bd330298b12bf05650357bfabdb6ecaa9767053f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/team/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/team/scenario/raw/lcbhard_3_oneoff_test.txt": "f600ec6338b2f9ab069eb5f1823e1837a19c1794423a03ee7b48fcaa8919e1d7", @@ -16558,7 +16562,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/team/scenario/raw/lcbhard_3_rows.json": "373b9802e1b13b0723183df699d11d409d92e3ae5d9fade4ef0d566aa7241d3a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/team/scenario/record.json": "31a166abe3dab04e04bd3bba58c683579fe5c53c72e5f6f08bbb92b29a36546f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/team/scenario/source.md": "0cb1438ca9a9a026b8ae7be4119b68d4a13abcc59b3ae9c2f5ca1eb87c64833e", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/team/task.json": "aeff528b932e12361bf3cadae482db547aabea03eafff1c8359b718dbb4a1e8d", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/team/task.json": "d903ae6849e9b51395f56b57f8b3b2a4de4f2b0d6ce1b876471335be5376b0d9", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16571,13 +16575,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/task.toml": "69552f7925fbf45fed5bccb7c0e4727729bccec898e51d95e1c202ca766b897c", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/task.toml": "9a7f333b02a2986235cb96914e02f7e1ade8a5a233ef14088c9d15720e6bf983", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/tests/expected.json": "1e0a3b26079f510e5316ec86f403e11d2b0285791d7e2879de12d1213435921f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/tests/scenario/episode.yaml": "d1efdcf9156a8e3fd600b667bd330298b12bf05650357bfabdb6ecaa9767053f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/tests/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/tests/scenario/raw/lcbhard_3_oneoff_test.txt": "f600ec6338b2f9ab069eb5f1823e1837a19c1794423a03ee7b48fcaa8919e1d7", @@ -16600,14 +16604,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/docker-compose.yaml": "2c9b4614a31bfc54edae2ed45100266a5b41575c445fc2009022e0f15fd3ab87", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/team/scenario/episode.yaml": "d1efdcf9156a8e3fd600b667bd330298b12bf05650357bfabdb6ecaa9767053f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/team/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/team/scenario/raw/lcbhard_3_oneoff_test.txt": "f600ec6338b2f9ab069eb5f1823e1837a19c1794423a03ee7b48fcaa8919e1d7", @@ -16616,7 +16620,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/team/scenario/raw/lcbhard_3_rows.json": "373b9802e1b13b0723183df699d11d409d92e3ae5d9fade4ef0d566aa7241d3a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/team/scenario/record.json": "31a166abe3dab04e04bd3bba58c683579fe5c53c72e5f6f08bbb92b29a36546f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/team/scenario/source.md": "0cb1438ca9a9a026b8ae7be4119b68d4a13abcc59b3ae9c2f5ca1eb87c64833e", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/team/task.json": "4445c6889b494aa171cbdace20044ac0387a5d80cbe847c0b125b5b2126b3555", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/team/task.json": "c9f70977e9a807f82962a321a104fbe9aebb352558f72a1a5b6dff1af2491f2d", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16629,13 +16633,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/task.toml": "cd688de84bb01f57d6528513e1bd55aa3cf47828c0190b2eb8643c7f48f465ef", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/task.toml": "8d91f32a50fbe09638d34c122dd192f790752e8636afebc04cd50845a1709001", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/tests/expected.json": "ebb9ce5697152e989369a0c1d9755454d829c6675313b5a6b225885c8c14b35a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/tests/scenario/episode.yaml": "d1efdcf9156a8e3fd600b667bd330298b12bf05650357bfabdb6ecaa9767053f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/tests/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/tests/scenario/raw/lcbhard_3_oneoff_test.txt": "f600ec6338b2f9ab069eb5f1823e1837a19c1794423a03ee7b48fcaa8919e1d7", @@ -16658,20 +16662,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/docker-compose.yaml": "68c5c60c320148b8c4a084b88163529bb53427d8d53fdf5dd72b34945ade3e92", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/team/scenario/episode.yaml": "c5bd6637185db233db0d6ac2666f823a1d0b7de41afcfed826e134567631c5b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/team/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/team/scenario/prefill.json": "547f0308d1fb457fea30f0042f759709e292762e98793ad50cc5c46af8a1fe81", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/team/scenario/record.json": "31a166abe3dab04e04bd3bba58c683579fe5c53c72e5f6f08bbb92b29a36546f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/team/scenario/source.md": "0cb1438ca9a9a026b8ae7be4119b68d4a13abcc59b3ae9c2f5ca1eb87c64833e", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/team/task.json": "1d4132bb8f476484ea08c176d92745e1097773c846f906e8638d64f180c5616e", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/team/task.json": "775e32e6fdf3b960068bac00d66e8f9a13e792e4067939564c6fa41994092079", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16684,13 +16688,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/task.toml": "bb7884ce27293d0b12e7e9233c9fc1483a453844f429c0f40b5fd2d67894623c", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/task.toml": "a9ceecfa042ed556c37b13bf9b927fbbf57afc1d509db14e31b421a36f13fe32", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/tests/expected.json": "df1281390a2f346bfa217d6dce711762ef83631aa9215ff52137017cab5cb205", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/tests/scenario/episode.yaml": "c5bd6637185db233db0d6ac2666f823a1d0b7de41afcfed826e134567631c5b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/tests/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/tests/scenario/prefill.json": "547f0308d1fb457fea30f0042f759709e292762e98793ad50cc5c46af8a1fe81", @@ -16710,20 +16714,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/docker-compose.yaml": "a2d9eee9e996b3ffa1e57ac5fe8b6a9e1bcfc4cadd68081e826b20b1dd4e50ab", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/team/scenario/episode.yaml": "c5bd6637185db233db0d6ac2666f823a1d0b7de41afcfed826e134567631c5b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/team/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/team/scenario/prefill.json": "547f0308d1fb457fea30f0042f759709e292762e98793ad50cc5c46af8a1fe81", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/team/scenario/record.json": "31a166abe3dab04e04bd3bba58c683579fe5c53c72e5f6f08bbb92b29a36546f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/team/scenario/source.md": "0cb1438ca9a9a026b8ae7be4119b68d4a13abcc59b3ae9c2f5ca1eb87c64833e", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/team/task.json": "066e57e80dd5503f81829214a8a0e5990c6d6837dc185041cca7bd6c18f5d6fb", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/team/task.json": "a9bd56b799cda26adf8bddc29f7444984822442b53d15bd606a39e9febf394af", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16736,13 +16740,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/task.toml": "fef710b703b25e2672904775b015b06499e97b87a173bbc5f339d19c4d1c075d", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/task.toml": "2f84bf3d67cd11e788ecfe81bbe5df6d59fc8ba35775bf211537e293785076ef", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/tests/expected.json": "3aaa2c3267927d46a482dc34466091d04c711dc90dc1b9e4522f3a289c02ebae", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/tests/scenario/episode.yaml": "c5bd6637185db233db0d6ac2666f823a1d0b7de41afcfed826e134567631c5b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/tests/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/tests/scenario/prefill.json": "547f0308d1fb457fea30f0042f759709e292762e98793ad50cc5c46af8a1fe81", @@ -16762,20 +16766,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/docker-compose.yaml": "39a23334de805e420e7f3405f8df603848681205c94172d136cc64a5fc144f00", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/team/scenario/episode.yaml": "c5bd6637185db233db0d6ac2666f823a1d0b7de41afcfed826e134567631c5b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/team/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/team/scenario/prefill.json": "547f0308d1fb457fea30f0042f759709e292762e98793ad50cc5c46af8a1fe81", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/team/scenario/record.json": "31a166abe3dab04e04bd3bba58c683579fe5c53c72e5f6f08bbb92b29a36546f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/team/scenario/source.md": "0cb1438ca9a9a026b8ae7be4119b68d4a13abcc59b3ae9c2f5ca1eb87c64833e", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/team/task.json": "0f22cda487b9d2185acfb4da4852d9f4d8295d0952a62837a51e10439f6764fb", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/team/task.json": "01fe6d4e5e6c86c7e45cfda52dda4aab7b4f3b26bfed0f2991b0ff6644b3aedc", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16788,13 +16792,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/task.toml": "e65badfeead87afc19f41e81e3ffe341e59d19f6a1a7c2913da029b2c3356ebe", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/task.toml": "8767ff3106036d2e88df41b31193bcf367558e64f272618cc35b68a7b1fb6b65", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/tests/expected.json": "9c14258e6590e4af6364b08854fe3cb9fee401eda0f35d9727393ec6f8f1b7f7", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/tests/scenario/episode.yaml": "c5bd6637185db233db0d6ac2666f823a1d0b7de41afcfed826e134567631c5b6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/tests/scenario/notes.md": "a613f59dc247fe8deffe3a51b6e670559452ee1af94341b56b088e8ab1838338", "tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/tests/scenario/prefill.json": "547f0308d1fb457fea30f0042f759709e292762e98793ad50cc5c46af8a1fe81", @@ -16814,14 +16818,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/docker-compose.yaml": "e92212de438fa36f3c41f5b0b95e40c4776e1824694583ee7579c32a1f1119be", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/team/scenario/episode.yaml": "99abe84539632446aea873e4a67d31d2f94026159d1ef56ee5c0f276e97a8868", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/team/scenario/notes.md": "9b68811ef78d528499d3af32fe6d53a44709fa02a60df114ad786ed24c5fed99", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/team/scenario/raw/lcbhard_8_oneoff_test.txt": "684f46fb110963836c7a0796305dd36973413e3de1d63256bc3c3a1036d8eddf", @@ -16830,7 +16834,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/team/scenario/raw/lcbhard_8_rows.json": "9246ad3e4d61d4671755e31fc9be7452efa2e3701ca6ae58d0890876bb733cd2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/team/scenario/record.json": "3435f497bb6283d427fe1acfee0258ce0e2520d796e940f97627fe3c9266a44d", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/team/scenario/source.md": "1b7491c3e3c709e341fb981803a91333d40e385c4752996e9cc2019511e9248c", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/team/task.json": "f78748a0d1437245807fef7dd5ca5a3bd69324ea4ac46c33502e09c15c90d9bc", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/team/task.json": "1f5810ac2978309ac7cc0e72001100a1a719073abdf53ba0a24cade968e72e9f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16843,13 +16847,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/task.toml": "fae1eeeb93af57b9fb653565a216cf82577c105e917408a38791398a4a2aad66", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/task.toml": "8b93390585a4350d33be50a60d9fa8a7c5132f6f509ec25a6c20bc14ed2431d6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/tests/expected.json": "36e89d96b5743714ff299e2bb2d93df781d7c165e0b264047bd1b601b22de120", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/tests/scenario/episode.yaml": "99abe84539632446aea873e4a67d31d2f94026159d1ef56ee5c0f276e97a8868", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/tests/scenario/notes.md": "9b68811ef78d528499d3af32fe6d53a44709fa02a60df114ad786ed24c5fed99", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/tests/scenario/raw/lcbhard_8_oneoff_test.txt": "684f46fb110963836c7a0796305dd36973413e3de1d63256bc3c3a1036d8eddf", @@ -16872,14 +16876,14 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/docker-compose.yaml": "3e7aa4687eaba8e1c99ba68ff2962bf1b88d46794d661eff92da9d3af82c0a1c", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/team/scenario/episode.yaml": "99abe84539632446aea873e4a67d31d2f94026159d1ef56ee5c0f276e97a8868", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/team/scenario/notes.md": "9b68811ef78d528499d3af32fe6d53a44709fa02a60df114ad786ed24c5fed99", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/team/scenario/raw/lcbhard_8_oneoff_test.txt": "684f46fb110963836c7a0796305dd36973413e3de1d63256bc3c3a1036d8eddf", @@ -16888,7 +16892,7 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/team/scenario/raw/lcbhard_8_rows.json": "9246ad3e4d61d4671755e31fc9be7452efa2e3701ca6ae58d0890876bb733cd2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/team/scenario/record.json": "3435f497bb6283d427fe1acfee0258ce0e2520d796e940f97627fe3c9266a44d", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/team/scenario/source.md": "1b7491c3e3c709e341fb981803a91333d40e385c4752996e9cc2019511e9248c", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/team/task.json": "611614b27229bb426ef9b698d74e05fff2ca4ddd36c6419d7526236025924c18", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/team/task.json": "16bfd0f5aad75db73580952b5425203c5b5587d00145741e528bb9e9b33a54b5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16901,13 +16905,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/task.toml": "cf59f6009f6a5811824ef3e43762580483d619be8a9743355914d6510a2df1c0", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/task.toml": "08b72f5cb8810d828e61d1553994b9724ed6821ee9a0e67abfe87684c9ad6335", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/tests/expected.json": "bbc4734a7acb8ca5bf9b81014aa48c18454bfde9de0bcae6db5422539845478f", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/tests/scenario/episode.yaml": "99abe84539632446aea873e4a67d31d2f94026159d1ef56ee5c0f276e97a8868", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/tests/scenario/notes.md": "9b68811ef78d528499d3af32fe6d53a44709fa02a60df114ad786ed24c5fed99", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/tests/scenario/raw/lcbhard_8_oneoff_test.txt": "684f46fb110963836c7a0796305dd36973413e3de1d63256bc3c3a1036d8eddf", @@ -16930,20 +16934,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/docker-compose.yaml": "e3a24d6a1b338b0cfa6938f4cc877728a6824367f9c73f7009cd780252795713", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/team/scenario/episode.yaml": "bf57d6a2bb75b87d6310c9b2bae1f565c0fa09bc2063abeadef353f245beb857", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/team/scenario/notes.md": "9b68811ef78d528499d3af32fe6d53a44709fa02a60df114ad786ed24c5fed99", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/team/scenario/prefill.json": "695c7c5c31c81f1b3c77028425f661cea988d5589d7af78cf85c8720b2ed00f5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/team/scenario/record.json": "3435f497bb6283d427fe1acfee0258ce0e2520d796e940f97627fe3c9266a44d", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/team/scenario/source.md": "1b7491c3e3c709e341fb981803a91333d40e385c4752996e9cc2019511e9248c", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/team/task.json": "fa56b482be7a80f0fc37f2e37b6678e40d8ac7b7e846c2087f96917d3f37b48b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/team/task.json": "5c620303d0a2e62072084a55535f8eb229a6ea8d533f8d5bb6fc4f529df00968", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -16956,13 +16960,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/task.toml": "4373559c60329218b22131c79f875d4835ac271e5985d1d715bd49f3a08bb0f7", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/task.toml": "be6a182c639e2514260a42076b29f4f975ef2080f25cf985f183a865e6f315cc", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/tests/expected.json": "6b77b502dcfdfebdba5c9afc6ad1f134c725e9e66ee984c68ed9fc6ef46effe4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/tests/scenario/episode.yaml": "bf57d6a2bb75b87d6310c9b2bae1f565c0fa09bc2063abeadef353f245beb857", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/tests/scenario/notes.md": "9b68811ef78d528499d3af32fe6d53a44709fa02a60df114ad786ed24c5fed99", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/tests/scenario/prefill.json": "695c7c5c31c81f1b3c77028425f661cea988d5589d7af78cf85c8720b2ed00f5", @@ -16982,20 +16986,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/docker-compose.yaml": "36ede6c30cb18a39528a1d064ff0d4bd235a233b5e985ad29617f0ad855bb42a", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/team/scenario/episode.yaml": "bf57d6a2bb75b87d6310c9b2bae1f565c0fa09bc2063abeadef353f245beb857", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/team/scenario/notes.md": "9b68811ef78d528499d3af32fe6d53a44709fa02a60df114ad786ed24c5fed99", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/team/scenario/prefill.json": "695c7c5c31c81f1b3c77028425f661cea988d5589d7af78cf85c8720b2ed00f5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/team/scenario/record.json": "3435f497bb6283d427fe1acfee0258ce0e2520d796e940f97627fe3c9266a44d", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/team/scenario/source.md": "1b7491c3e3c709e341fb981803a91333d40e385c4752996e9cc2019511e9248c", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/team/task.json": "e40823556b7ec78323ff7ccdbaa7268d743ba522693e9ca16facbc44d6d36292", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/team/task.json": "da3cf0e841d1a18f3b77fd5fd5dc238adc746ec6e2068361744a9ece7dfbdf2c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17008,13 +17012,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/task.toml": "f759ff6e22ee06201459130b85c994f0c096a78fea8bcb859c5c0463e602a83e", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/task.toml": "5d47a31b0f0afb1de2a8ff670fc53e2fc55943edad1fcb2f406ff7b08b6f5394", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/tests/expected.json": "b8e0e28e4d84d670eef4e77700df543fe6772a03e7db96598ea3602950255fbe", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/tests/scenario/episode.yaml": "bf57d6a2bb75b87d6310c9b2bae1f565c0fa09bc2063abeadef353f245beb857", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/tests/scenario/notes.md": "9b68811ef78d528499d3af32fe6d53a44709fa02a60df114ad786ed24c5fed99", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/tests/scenario/prefill.json": "695c7c5c31c81f1b3c77028425f661cea988d5589d7af78cf85c8720b2ed00f5", @@ -17034,20 +17038,20 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/docker-compose.yaml": "3c4f31a29c9e43ff883ee79b56a90aaba37af954d153e74e03a0bfc36e35a3e1", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/team/scenario/episode.yaml": "bf57d6a2bb75b87d6310c9b2bae1f565c0fa09bc2063abeadef353f245beb857", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/team/scenario/notes.md": "9b68811ef78d528499d3af32fe6d53a44709fa02a60df114ad786ed24c5fed99", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/team/scenario/prefill.json": "695c7c5c31c81f1b3c77028425f661cea988d5589d7af78cf85c8720b2ed00f5", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/team/scenario/record.json": "3435f497bb6283d427fe1acfee0258ce0e2520d796e940f97627fe3c9266a44d", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/team/scenario/source.md": "1b7491c3e3c709e341fb981803a91333d40e385c4752996e9cc2019511e9248c", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/team/task.json": "80387f02be3a4f60401cad94026580c6be499aa7a240e5a8d924a1aa0a6243b8", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/team/task.json": "468f7e44d2a54d24557e1bda8773ec001c43f0473d028093443c1ba03c682787", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17060,13 +17064,13 @@ "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/task.toml": "762ad2b9c62fb8caa25b974609ae0d8ce49a3cdf56f3e5d9465e246588c09bb9", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/task.toml": "c203a1c3bf9b477b9365acde1504f1afa313f9698c62d6c0b95e05995ed1ffb0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/tests/expected.json": "208367eac57f8d0550c633aa34cdea6213c0910ecb7317278e2dabec2f4200e0", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/tests/scenario/episode.yaml": "bf57d6a2bb75b87d6310c9b2bae1f565c0fa09bc2063abeadef353f245beb857", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/tests/scenario/notes.md": "9b68811ef78d528499d3af32fe6d53a44709fa02a60df114ad786ed24c5fed99", "tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/tests/scenario/prefill.json": "695c7c5c31c81f1b3c77028425f661cea988d5589d7af78cf85c8720b2ed00f5", @@ -17086,19 +17090,19 @@ "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/docker-compose.yaml": "cb50a0d94b7ecf4743f10293e24c7914c84e34b798e28b924c794f30623508fc", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/team/scenario/episode.yaml": "0132cb6492607e51d1888f0903f2598789b73a47341ffc1c3d2f14aa07839c0f", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/team/scenario/notes.md": "b7e78e7b711c1df77c3ecfda4a6774d4fe8f26d38dc70c109ebe02b8585802f3", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/team/scenario/record.json": "396a146fbf3b85dd1160f50cd89d6996f3c9ba482f7c18446d6065eef616ad73", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/team/scenario/source.md": "3cd8b226b263cf68b2545ba03521a9c18b5ca38d1e1794f5defaaf67a596c715", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/team/task.json": "a4ffa3220dc097f3fa25cae5b1d3e245e72db38b7ccdef553b6e33853db7b186", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/team/task.json": "3260e1030a233a38020a2905e5d4f4eaaabe34f0edf38d99029d1fdd6b500b7e", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17111,13 +17115,13 @@ "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/task.toml": "f97935dc4b3c3afa40f206fa49088c0803c089ddf877837d7ed162938fc3af40", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/task.toml": "82e848fb4620c3df119647e0ba3102f71ea52f3030bde142718ede6db50cd9d9", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/tests/expected.json": "946476aa45b74bb0bd4623cbce6e6adf495cc25e57612b61877990118ac94ecd", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/tests/scenario/episode.yaml": "0132cb6492607e51d1888f0903f2598789b73a47341ffc1c3d2f14aa07839c0f", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/tests/scenario/notes.md": "b7e78e7b711c1df77c3ecfda4a6774d4fe8f26d38dc70c109ebe02b8585802f3", "tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/tests/scenario/record.json": "396a146fbf3b85dd1160f50cd89d6996f3c9ba482f7c18446d6065eef616ad73", @@ -17136,19 +17140,19 @@ "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/docker-compose.yaml": "bfa92f00407d1b5ba5b2855df6392fd9102b017e368fcabc76eb63af3486f673", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/team/scenario/episode.yaml": "0132cb6492607e51d1888f0903f2598789b73a47341ffc1c3d2f14aa07839c0f", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/team/scenario/notes.md": "b7e78e7b711c1df77c3ecfda4a6774d4fe8f26d38dc70c109ebe02b8585802f3", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/team/scenario/record.json": "396a146fbf3b85dd1160f50cd89d6996f3c9ba482f7c18446d6065eef616ad73", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/team/scenario/source.md": "3cd8b226b263cf68b2545ba03521a9c18b5ca38d1e1794f5defaaf67a596c715", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/team/task.json": "627d2ad62995fe3b3aa5cfda4f9ead971606c2e363a500bccae5ef7b524513cc", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/team/task.json": "212316a4c598e2a21ac80f42df90e031a9361e4b2a56ee4e6ffced15a42ccc39", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17161,13 +17165,13 @@ "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/task.toml": "8ae38dcf58b819dbd419113cf29dbf1ebfc891c43cde348fb3cd041328a34835", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/task.toml": "ad9c564823a23e864646b25fbfca5c2f8854f4fc3b80106ca1f1ba8750a7bdbc", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/tests/expected.json": "3b4b587642eff8eb6c7ef23db370221a3bfe61585581ac05f1aa77e5b55379fb", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/tests/scenario/episode.yaml": "0132cb6492607e51d1888f0903f2598789b73a47341ffc1c3d2f14aa07839c0f", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/tests/scenario/notes.md": "b7e78e7b711c1df77c3ecfda4a6774d4fe8f26d38dc70c109ebe02b8585802f3", "tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/tests/scenario/record.json": "396a146fbf3b85dd1160f50cd89d6996f3c9ba482f7c18446d6065eef616ad73", @@ -17186,20 +17190,20 @@ "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/docker-compose.yaml": "271e5e4740f3193b1ae59b79159ef6c4638ab9dff9098c00123da78cbf068020", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/team/scenario/episode.yaml": "1e68e0ae55040c9aba4290a5fe5b398eee8f43f6ccbce4a196d69222a261d785", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/team/scenario/notes.md": "b7e78e7b711c1df77c3ecfda4a6774d4fe8f26d38dc70c109ebe02b8585802f3", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/team/scenario/prefill.json": "60c65efde85cb0ef178013a12f9a497e41db37b2216f5b05aa64e871b2eed545", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/team/scenario/record.json": "396a146fbf3b85dd1160f50cd89d6996f3c9ba482f7c18446d6065eef616ad73", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/team/scenario/source.md": "3cd8b226b263cf68b2545ba03521a9c18b5ca38d1e1794f5defaaf67a596c715", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/team/task.json": "c06fcb9d8815b545357fb4a4b7ff46e22ba08d5e5a9c7736ec48c84741ba4b4a", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/team/task.json": "5bd9f617ffb3d9ae7244cdb7cf027c5698dd657fe3b5b25df040e43f397d2391", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17212,13 +17216,13 @@ "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/task.toml": "3e3294f23cc8ec3787dd5c968dab04d75aeaa5604795fbca7845dd245df84e76", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/task.toml": "fde3e68326935183df2befa5eea33d01d35f65866bafc16232b2be1dd221fea4", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/tests/expected.json": "f85f4e3cbbd3d1a1bd31ac324e83925393fea5431c83011824a95368d02e39a6", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/tests/scenario/episode.yaml": "1e68e0ae55040c9aba4290a5fe5b398eee8f43f6ccbce4a196d69222a261d785", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/tests/scenario/notes.md": "b7e78e7b711c1df77c3ecfda4a6774d4fe8f26d38dc70c109ebe02b8585802f3", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/tests/scenario/prefill.json": "60c65efde85cb0ef178013a12f9a497e41db37b2216f5b05aa64e871b2eed545", @@ -17238,20 +17242,20 @@ "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/docker-compose.yaml": "69702215f3f5c3d4d8fed15ce4023c7e4c31746d7bdee0a15b60531f6637ed13", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/team/scenario/episode.yaml": "1e68e0ae55040c9aba4290a5fe5b398eee8f43f6ccbce4a196d69222a261d785", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/team/scenario/notes.md": "b7e78e7b711c1df77c3ecfda4a6774d4fe8f26d38dc70c109ebe02b8585802f3", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/team/scenario/prefill.json": "60c65efde85cb0ef178013a12f9a497e41db37b2216f5b05aa64e871b2eed545", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/team/scenario/record.json": "396a146fbf3b85dd1160f50cd89d6996f3c9ba482f7c18446d6065eef616ad73", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/team/scenario/source.md": "3cd8b226b263cf68b2545ba03521a9c18b5ca38d1e1794f5defaaf67a596c715", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/team/task.json": "6ff8b13152a8a2ebda22de79d3881ba959af131d4a84eade3e790db2de3da922", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/team/task.json": "8e53f274c639beb969aaca6d452ce2d064c863f11330749731b344f878121d30", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17264,13 +17268,13 @@ "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/task.toml": "b36dc9db32851107b1e1c24054aedf2570d97e998d6005f5f7cf46760ec49b44", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/task.toml": "46ab165613bfcc8e06ebca70a081402dadcec9598055b5a0c6de8dc4f458d703", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/tests/expected.json": "3ae3668c0f4165ff562b39e8b7981b82d7e304b1fbf32b3e159b21bcb0670396", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/tests/scenario/episode.yaml": "1e68e0ae55040c9aba4290a5fe5b398eee8f43f6ccbce4a196d69222a261d785", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/tests/scenario/notes.md": "b7e78e7b711c1df77c3ecfda4a6774d4fe8f26d38dc70c109ebe02b8585802f3", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/tests/scenario/prefill.json": "60c65efde85cb0ef178013a12f9a497e41db37b2216f5b05aa64e871b2eed545", @@ -17290,20 +17294,20 @@ "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/docker-compose.yaml": "5a28451f0647c04c5eb6133c3c5b7fb9df846c55db1952aae0b1dca5f9fdb2b3", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/team/scenario/episode.yaml": "1e68e0ae55040c9aba4290a5fe5b398eee8f43f6ccbce4a196d69222a261d785", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/team/scenario/notes.md": "b7e78e7b711c1df77c3ecfda4a6774d4fe8f26d38dc70c109ebe02b8585802f3", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/team/scenario/prefill.json": "60c65efde85cb0ef178013a12f9a497e41db37b2216f5b05aa64e871b2eed545", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/team/scenario/record.json": "396a146fbf3b85dd1160f50cd89d6996f3c9ba482f7c18446d6065eef616ad73", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/team/scenario/source.md": "3cd8b226b263cf68b2545ba03521a9c18b5ca38d1e1794f5defaaf67a596c715", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/team/task.json": "57cc7f40a13dc49b119a0cd206a7ea51905cd9b3a49fc49253d1bdd572c9b107", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/team/task.json": "7e52643ce5e5cb5c3ff05491d1a313b91ede016d7b46a5f56fcf4dfe37985ea1", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17316,13 +17320,13 @@ "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/task.toml": "f640012b0220a7d67abbbc5d8cf892661275e00e442ab77ab7407be0bac50625", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/task.toml": "d5b07269a488900af918778c927d7131f84b697c41d32467339aec93d87aef1c", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/tests/expected.json": "146b1d8a71803b884d4d558f1c8d7d1d5346fe8f869cb5524da94bd5255251af", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/tests/scenario/episode.yaml": "1e68e0ae55040c9aba4290a5fe5b398eee8f43f6ccbce4a196d69222a261d785", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/tests/scenario/notes.md": "b7e78e7b711c1df77c3ecfda4a6774d4fe8f26d38dc70c109ebe02b8585802f3", "tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/tests/scenario/prefill.json": "60c65efde85cb0ef178013a12f9a497e41db37b2216f5b05aa64e871b2eed545", @@ -17342,19 +17346,19 @@ "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/docker-compose.yaml": "78e29d59336783ef7e009128afc079f1c681b4642dee2b571dcf9d4d90ad39d0", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/team/scenario/episode.yaml": "812b4ae3ff4f7ff01c27fae91dcebf95a2e5fb1ecb6a9ce29a8a5ae71307de4f", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/team/scenario/notes.md": "51ef4080a7b819ed31d9aab87be08907930fe0168aec441bc350e561319b88b9", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/team/scenario/record.json": "032c3ebf83d7189a696f4dc95363172c3a193b4d499253ba333c5ec195152a25", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/team/scenario/source.md": "5c9c14142ff6ca480ceb2bb1ef05790ba6ec9f670985b493424c7c12e59617e3", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/team/task.json": "7fb27cab897ba62511fd58dc99423a280ee823780de22ae88d022b3f0920f822", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/team/task.json": "4e84fffb9d9eb648b1edbe57d9db0333556ef498ef1493be001f47c74615c134", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17367,13 +17371,13 @@ "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/task.toml": "63d363428082a8f5c5fa64c5092ee064fb8bc3e9e41e10510ae6060fb8323af3", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/task.toml": "05e818b07792c08d9ca672fc42952b30eadbbc7095c5fd96d31b0525146f06dc", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/tests/expected.json": "74d6f99558dfa6256cf74ca7b9fc565d3081ffca25b8cf16914971eef4ef98d3", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/tests/scenario/episode.yaml": "812b4ae3ff4f7ff01c27fae91dcebf95a2e5fb1ecb6a9ce29a8a5ae71307de4f", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/tests/scenario/notes.md": "51ef4080a7b819ed31d9aab87be08907930fe0168aec441bc350e561319b88b9", "tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/tests/scenario/record.json": "032c3ebf83d7189a696f4dc95363172c3a193b4d499253ba333c5ec195152a25", @@ -17392,19 +17396,19 @@ "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/docker-compose.yaml": "3a26e69920711a0059c80d371d31235e902061b25b37df9cbfa7a2b8e19f7d20", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/team/scenario/episode.yaml": "812b4ae3ff4f7ff01c27fae91dcebf95a2e5fb1ecb6a9ce29a8a5ae71307de4f", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/team/scenario/notes.md": "51ef4080a7b819ed31d9aab87be08907930fe0168aec441bc350e561319b88b9", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/team/scenario/record.json": "032c3ebf83d7189a696f4dc95363172c3a193b4d499253ba333c5ec195152a25", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/team/scenario/source.md": "5c9c14142ff6ca480ceb2bb1ef05790ba6ec9f670985b493424c7c12e59617e3", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/team/task.json": "5bb169b121fb97c7bb245072fbf27612cdd63555e09d5ef92375237c83e281e7", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/team/task.json": "a841e9746a42275a11260ef5b54ef1ae5a01f93013ef23c1dc899b8f82ebf53f", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17417,13 +17421,13 @@ "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/task.toml": "61e91e7577ab71dab7331660bd6844e54af53dc19c90afc2079b6d22c757fbb4", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/task.toml": "95aecfc0fd25d710c418f65c544b98a20760d4dec68172d1abf4db40ecfe7a85", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/tests/expected.json": "8787286267f8cdc97d6dbd77e07045c0b46a10f622a99b36343af340df261546", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/tests/scenario/episode.yaml": "812b4ae3ff4f7ff01c27fae91dcebf95a2e5fb1ecb6a9ce29a8a5ae71307de4f", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/tests/scenario/notes.md": "51ef4080a7b819ed31d9aab87be08907930fe0168aec441bc350e561319b88b9", "tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/tests/scenario/record.json": "032c3ebf83d7189a696f4dc95363172c3a193b4d499253ba333c5ec195152a25", @@ -17442,20 +17446,20 @@ "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/docker-compose.yaml": "cc68b9083d9ba2fb19a42af5bfe35771f9653c4e82b3728e104fcf6afb276c1b", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/team/scenario/episode.yaml": "22c4bcefb6526460b668d74e8ddd0eaedf4f7dfa3d6ca0afcf184c6e0557a9b8", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/team/scenario/notes.md": "51ef4080a7b819ed31d9aab87be08907930fe0168aec441bc350e561319b88b9", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/team/scenario/prefill.json": "f4b08800966eb99bb9c5f25e84a17ad8a3bcd747353544b0ec1b5e21c53c6a91", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/team/scenario/record.json": "032c3ebf83d7189a696f4dc95363172c3a193b4d499253ba333c5ec195152a25", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/team/scenario/source.md": "5c9c14142ff6ca480ceb2bb1ef05790ba6ec9f670985b493424c7c12e59617e3", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/team/task.json": "439b74ad87f13d1da2730c9a5baabb6912941caea72c10eb950a0d37ca9ccc3e", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/team/task.json": "089b4a89f5453f81647daed79f64ed43008bdf00b520d215e241a5191d4d20fb", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17468,13 +17472,13 @@ "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/task.toml": "861a9945a9b5f7b6edf865f4ae9db924ef31fdee22ebf05e8230ae2c5ae92a84", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/task.toml": "dba9760f276de4a14cb2362be2925465bd15a58cc74caab9293ef134aa013e0e", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/tests/expected.json": "0d2a2d280b656dd327145494dbb85f581d91583180f4e68f11d11443884d16c7", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/tests/scenario/episode.yaml": "22c4bcefb6526460b668d74e8ddd0eaedf4f7dfa3d6ca0afcf184c6e0557a9b8", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/tests/scenario/notes.md": "51ef4080a7b819ed31d9aab87be08907930fe0168aec441bc350e561319b88b9", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/tests/scenario/prefill.json": "f4b08800966eb99bb9c5f25e84a17ad8a3bcd747353544b0ec1b5e21c53c6a91", @@ -17494,20 +17498,20 @@ "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/docker-compose.yaml": "d63208d5bcc7f82c7e90c9620561787e349a0aba9e8dd689ca0768a8a818e013", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/team/scenario/episode.yaml": "22c4bcefb6526460b668d74e8ddd0eaedf4f7dfa3d6ca0afcf184c6e0557a9b8", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/team/scenario/notes.md": "51ef4080a7b819ed31d9aab87be08907930fe0168aec441bc350e561319b88b9", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/team/scenario/prefill.json": "f4b08800966eb99bb9c5f25e84a17ad8a3bcd747353544b0ec1b5e21c53c6a91", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/team/scenario/record.json": "032c3ebf83d7189a696f4dc95363172c3a193b4d499253ba333c5ec195152a25", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/team/scenario/source.md": "5c9c14142ff6ca480ceb2bb1ef05790ba6ec9f670985b493424c7c12e59617e3", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/team/task.json": "74a376f6d595da5e797eed11a3831a03ad104723ff5f497d31dde7bc11575b4c", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/team/task.json": "2adcfc3e9aafceb459cc9123814e64e938cd6aa96b2e8d5afd623f4f59e623ff", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17520,13 +17524,13 @@ "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/task.toml": "0682acb01ac80b8636cba37e01bbbcf72b4e6e94c1323560b3a82f3c6d017986", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/task.toml": "efb9b9b111530c1d77020d8ea1d09f238c79273499773897be60d4b1789c1fd9", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/tests/expected.json": "b2cbc3aa8d59172b78424f403f241523355578b004f623d2d4c6ca99a39691b7", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/tests/scenario/episode.yaml": "22c4bcefb6526460b668d74e8ddd0eaedf4f7dfa3d6ca0afcf184c6e0557a9b8", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/tests/scenario/notes.md": "51ef4080a7b819ed31d9aab87be08907930fe0168aec441bc350e561319b88b9", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/tests/scenario/prefill.json": "f4b08800966eb99bb9c5f25e84a17ad8a3bcd747353544b0ec1b5e21c53c6a91", @@ -17546,20 +17550,20 @@ "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/docker-compose.yaml": "2fcd8b303c4a19052b218a7fe9e35f86349939aa1e4baf094d35084aca25a02a", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/team/scenario/episode.yaml": "22c4bcefb6526460b668d74e8ddd0eaedf4f7dfa3d6ca0afcf184c6e0557a9b8", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/team/scenario/notes.md": "51ef4080a7b819ed31d9aab87be08907930fe0168aec441bc350e561319b88b9", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/team/scenario/prefill.json": "f4b08800966eb99bb9c5f25e84a17ad8a3bcd747353544b0ec1b5e21c53c6a91", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/team/scenario/record.json": "032c3ebf83d7189a696f4dc95363172c3a193b4d499253ba333c5ec195152a25", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/team/scenario/source.md": "5c9c14142ff6ca480ceb2bb1ef05790ba6ec9f670985b493424c7c12e59617e3", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/team/task.json": "028c019318bbaba0a6b095de24e70854912be2c19a4f09d4cf8f4559412f4e04", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/team/task.json": "03f103baf2f81a00be0a9fe60c22a51dedccf579ab5e4a510c1150d0eeac8251", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17572,13 +17576,13 @@ "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/task.toml": "83576e67d1efa91672a641fa44ae0617ddc671320864c73737569dc001ec0220", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/task.toml": "41a741148751ae2a59480efc27a245747899eab7302639ec6aa584b9cf7217a9", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/tests/expected.json": "31fe5930440561067de60e27ea2802e3d272a3604c01877b7d3500360a96084b", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/tests/scenario/episode.yaml": "22c4bcefb6526460b668d74e8ddd0eaedf4f7dfa3d6ca0afcf184c6e0557a9b8", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/tests/scenario/notes.md": "51ef4080a7b819ed31d9aab87be08907930fe0168aec441bc350e561319b88b9", "tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/tests/scenario/prefill.json": "f4b08800966eb99bb9c5f25e84a17ad8a3bcd747353544b0ec1b5e21c53c6a91", @@ -17598,19 +17602,19 @@ "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/docker-compose.yaml": "fb5c7a89805958adf3de3d4952bad1410e78aa42b6fcafc94c87bbdec0df2871", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/team/scenario/episode.yaml": "bd2f77258597f4ccd1bd1cd481b9d487d118780a8619aeffa4747822aebd2111", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/team/scenario/notes.md": "8a7fecdfbe9fd75781b81cd6fe6a00babe89644b6fc9b3ce9af7822c172da85f", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/team/scenario/record.json": "5f6bcbdd3a746b6760eb2ed1b56de1729d0da955ad64d350176a63bcf4b329a3", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/team/scenario/source.md": "adfad37c5ed0e84d58245a017a7df0c281c4326c8b8613879f2eefd7efa62e49", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/team/task.json": "b04b5ae6455d634d1e174f40b50bee77c3815f6a15df4b4c83bd385ea72a86d2", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/team/task.json": "e4c68243e7a3652118c3c247e2610a686a0405a424950261a56e2cc0a38876ac", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17623,13 +17627,13 @@ "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/task.toml": "2279b2f21351419aba5460552c188e5da5903fca9d1621923232613588e0305e", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/task.toml": "99139be56475e1b760b729baef9af13fafebfae9825489478890d40e519b6779", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/tests/expected.json": "1c1b1da0138616cb46d52d17cdc3821fff32fd18907e1efbc2c917293a972c49", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/tests/scenario/episode.yaml": "bd2f77258597f4ccd1bd1cd481b9d487d118780a8619aeffa4747822aebd2111", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/tests/scenario/notes.md": "8a7fecdfbe9fd75781b81cd6fe6a00babe89644b6fc9b3ce9af7822c172da85f", "tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/tests/scenario/record.json": "5f6bcbdd3a746b6760eb2ed1b56de1729d0da955ad64d350176a63bcf4b329a3", @@ -17648,19 +17652,19 @@ "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/docker-compose.yaml": "6168b3a84a1f66f078b3f4aac2c3d289b53187b17112e36ebb22f0afa377a500", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/team/scenario/episode.yaml": "bd2f77258597f4ccd1bd1cd481b9d487d118780a8619aeffa4747822aebd2111", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/team/scenario/notes.md": "8a7fecdfbe9fd75781b81cd6fe6a00babe89644b6fc9b3ce9af7822c172da85f", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/team/scenario/record.json": "5f6bcbdd3a746b6760eb2ed1b56de1729d0da955ad64d350176a63bcf4b329a3", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/team/scenario/source.md": "adfad37c5ed0e84d58245a017a7df0c281c4326c8b8613879f2eefd7efa62e49", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/team/task.json": "2f4e797fcc374817c30fc69c7521fe7c2ff5790741378295a2e0f114cfbb15c7", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/team/task.json": "783702870cd4dab6d17d0790a2fa86764dc5910cdd21de3c19662acd2ef33a65", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17673,13 +17677,13 @@ "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/task.toml": "b33d7b031e08b77b48c914f2afc35713e993f59e6b64c54c88483d4679362cc0", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/task.toml": "bf53a875efaafd3b1c922dcf0f4f54ed5c17061c6f3d093a9aca3e90fadfeefe", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/tests/expected.json": "bd6e1451f8e6b2cef505d1915343b8ac583f1dfacf0f2db7d5e888c3f9200679", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/tests/scenario/episode.yaml": "bd2f77258597f4ccd1bd1cd481b9d487d118780a8619aeffa4747822aebd2111", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/tests/scenario/notes.md": "8a7fecdfbe9fd75781b81cd6fe6a00babe89644b6fc9b3ce9af7822c172da85f", "tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/tests/scenario/record.json": "5f6bcbdd3a746b6760eb2ed1b56de1729d0da955ad64d350176a63bcf4b329a3", @@ -17698,20 +17702,20 @@ "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/docker-compose.yaml": "5e4a8029bb2e005536d1c2a5709575fef1a9472efa88a5133db6f40e9071e9a7", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/team/scenario/episode.yaml": "e746238dcd13e408cf1f55ba5c3695ac0c713324d1b29ea052596f1570d3023b", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/team/scenario/notes.md": "8a7fecdfbe9fd75781b81cd6fe6a00babe89644b6fc9b3ce9af7822c172da85f", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/team/scenario/prefill.json": "25c8eb1b4d777a3bb9b68fc2459c29e8df785ef199c66de013348b71e92d1971", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/team/scenario/record.json": "5f6bcbdd3a746b6760eb2ed1b56de1729d0da955ad64d350176a63bcf4b329a3", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/team/scenario/source.md": "adfad37c5ed0e84d58245a017a7df0c281c4326c8b8613879f2eefd7efa62e49", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/team/task.json": "a997ee38e7d3ae4a6595e81d7eb2396432e5af9fb3c4c2a4135676aa83e8d0cf", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/team/task.json": "b9b905ebcffe6158fb691bac36c357db83c707e15361b232dcbd4be1a8b096ba", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17724,13 +17728,13 @@ "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/task.toml": "59c1f4732468912073f34efc82fdbc56101c051627c6a8c1d07a65b73227f818", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/task.toml": "633fefb784dfba8e71c7e087e1ebefd1dd35ca6d5c222ce56a877bd273ff94e2", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/tests/expected.json": "3c26a3387be5c5d2d94d0a780bf96ef05b27f3dcc96b9e47318fabae98e8a848", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/tests/scenario/episode.yaml": "e746238dcd13e408cf1f55ba5c3695ac0c713324d1b29ea052596f1570d3023b", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/tests/scenario/notes.md": "8a7fecdfbe9fd75781b81cd6fe6a00babe89644b6fc9b3ce9af7822c172da85f", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/tests/scenario/prefill.json": "25c8eb1b4d777a3bb9b68fc2459c29e8df785ef199c66de013348b71e92d1971", @@ -17750,20 +17754,20 @@ "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/docker-compose.yaml": "439a6475eccc9046d8ec4d5ebe8166e819072e5779ef43435384d3db17c71b3a", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/team/scenario/episode.yaml": "e746238dcd13e408cf1f55ba5c3695ac0c713324d1b29ea052596f1570d3023b", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/team/scenario/notes.md": "8a7fecdfbe9fd75781b81cd6fe6a00babe89644b6fc9b3ce9af7822c172da85f", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/team/scenario/prefill.json": "25c8eb1b4d777a3bb9b68fc2459c29e8df785ef199c66de013348b71e92d1971", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/team/scenario/record.json": "5f6bcbdd3a746b6760eb2ed1b56de1729d0da955ad64d350176a63bcf4b329a3", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/team/scenario/source.md": "adfad37c5ed0e84d58245a017a7df0c281c4326c8b8613879f2eefd7efa62e49", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/team/task.json": "b07aef0be47113b2df114ce2cc5d24cac62ac1e711d49e8ff73e4b690b310d6b", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/team/task.json": "2e0d3035538ef348164d66bfe4118ff261d3d57fa08a451e827eda39abcac201", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17776,13 +17780,13 @@ "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/task.toml": "e92e2f99812c32d910a06e6546cf817ee87bbf4a2e675fa106da7b66dc31320c", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/task.toml": "e5779de14db5a4b3432be00a445e8e6221def22bc731ff55d50aff3ee1c6d597", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/tests/expected.json": "3e8a0a905e6202a3e6cbe6cda245ecc7145371bc60e5423a47dcb5a84ab67692", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/tests/scenario/episode.yaml": "e746238dcd13e408cf1f55ba5c3695ac0c713324d1b29ea052596f1570d3023b", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/tests/scenario/notes.md": "8a7fecdfbe9fd75781b81cd6fe6a00babe89644b6fc9b3ce9af7822c172da85f", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/tests/scenario/prefill.json": "25c8eb1b4d777a3bb9b68fc2459c29e8df785ef199c66de013348b71e92d1971", @@ -17802,20 +17806,20 @@ "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/docker-compose.yaml": "fe46029466bbb560bda5b1d8e2fbdd298989c9e30772abf47b63d445df3f6e9a", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/team/scenario/episode.yaml": "e746238dcd13e408cf1f55ba5c3695ac0c713324d1b29ea052596f1570d3023b", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/team/scenario/notes.md": "8a7fecdfbe9fd75781b81cd6fe6a00babe89644b6fc9b3ce9af7822c172da85f", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/team/scenario/prefill.json": "25c8eb1b4d777a3bb9b68fc2459c29e8df785ef199c66de013348b71e92d1971", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/team/scenario/record.json": "5f6bcbdd3a746b6760eb2ed1b56de1729d0da955ad64d350176a63bcf4b329a3", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/team/scenario/source.md": "adfad37c5ed0e84d58245a017a7df0c281c4326c8b8613879f2eefd7efa62e49", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/team/task.json": "340e24239a91f54be7f96780ffcbfb2995acd8e95e617d031b8e8ddf3ce319f0", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/team/task.json": "76c42c48155d496c2f789b3c0c3160390f51a88bdad79fa96fc3c79223bee955", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17828,13 +17832,13 @@ "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/task.toml": "a615673ff6282e87a003ba96970d6ff2066820dad9de42f0f4790448de93ccb9", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/task.toml": "27c16ef6856a5aed4a77c017ee463d9d26b9161572c71ce02f20789d3d88d676", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/tests/expected.json": "479353d68c5217847006f600e9144ae0c2d11e5ed96ac28cde4f7dbc5a27fe40", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/tests/scenario/episode.yaml": "e746238dcd13e408cf1f55ba5c3695ac0c713324d1b29ea052596f1570d3023b", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/tests/scenario/notes.md": "8a7fecdfbe9fd75781b81cd6fe6a00babe89644b6fc9b3ce9af7822c172da85f", "tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/tests/scenario/prefill.json": "25c8eb1b4d777a3bb9b68fc2459c29e8df785ef199c66de013348b71e92d1971", @@ -17854,19 +17858,19 @@ "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/docker-compose.yaml": "534a5d8c37561d9569e0740da8eb6d517f6f57ce5860fa11e9de838f7627af94", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/team/scenario/episode.yaml": "987a75bdd93102aaa0ddd43e42e68098fb160f65ce98c34451ec9b43e2cbc22c", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/team/scenario/notes.md": "6fc0439da0df692dc22d960b4d303611eb18621a07515dac39c5f6aae8baa04e", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/team/scenario/record.json": "9cd4f668dd0657d5b012c9618e0d5a9e0a82b18c895b90ac098f0e0677d3c32e", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/team/scenario/source.md": "919e0e88a35eeb85adfc6ebcf83977847a3a74307386b5b49d496ff060ba3d40", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/team/task.json": "e9eaadbe0c163a6324cc198b2533f62e8fc68174e8504eb683f550910852c78c", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/team/task.json": "0a0217850b8d4c9727280ac04063c5ad03f99e9b22cc59415bd6ff48fa9f9518", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17879,13 +17883,13 @@ "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/task.toml": "4878e6f92c745e0fb3841f6dc3103700877ee19078cbf4539bac5f07e8c91756", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/task.toml": "9efc867544565965a42f0abdd484f79eb7071465aff075aa2b1eb1b20cca0cfe", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/tests/expected.json": "b283f20a8db8c98e667b8c11e25b7ca60b21ffb787cf7f05eec0b27101db5b2b", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/tests/scenario/episode.yaml": "987a75bdd93102aaa0ddd43e42e68098fb160f65ce98c34451ec9b43e2cbc22c", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/tests/scenario/notes.md": "6fc0439da0df692dc22d960b4d303611eb18621a07515dac39c5f6aae8baa04e", "tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/tests/scenario/record.json": "9cd4f668dd0657d5b012c9618e0d5a9e0a82b18c895b90ac098f0e0677d3c32e", @@ -17904,19 +17908,19 @@ "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/docker-compose.yaml": "984f5998b2b4038d5883de46c8ac6abeb408924910fd4cc38e6552eb406fe0ca", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/team/scenario/episode.yaml": "987a75bdd93102aaa0ddd43e42e68098fb160f65ce98c34451ec9b43e2cbc22c", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/team/scenario/notes.md": "6fc0439da0df692dc22d960b4d303611eb18621a07515dac39c5f6aae8baa04e", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/team/scenario/record.json": "9cd4f668dd0657d5b012c9618e0d5a9e0a82b18c895b90ac098f0e0677d3c32e", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/team/scenario/source.md": "919e0e88a35eeb85adfc6ebcf83977847a3a74307386b5b49d496ff060ba3d40", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/team/task.json": "ef03c366529267e87fce6fb6fd89cf64dd7995b29b249503fbc3809f201e9daf", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/team/task.json": "f316d8b3fdcb4fd77932f1368ca92895ecd484618b14815fc34e14fba9f5facf", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17929,13 +17933,13 @@ "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/task.toml": "040c3945f362045dac3321cdb61017420ae2ca23df43d371f98da3a9239c2c04", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/task.toml": "390ac6a0a23debc71471d60292b5f5d478cb0c2860201a261532f54f281de175", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/tests/expected.json": "3b5f5f03574b8385a47c71398f5d0bcf6ce4b5e864935312cdfe394372f32d7a", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/tests/scenario/episode.yaml": "987a75bdd93102aaa0ddd43e42e68098fb160f65ce98c34451ec9b43e2cbc22c", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/tests/scenario/notes.md": "6fc0439da0df692dc22d960b4d303611eb18621a07515dac39c5f6aae8baa04e", "tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/tests/scenario/record.json": "9cd4f668dd0657d5b012c9618e0d5a9e0a82b18c895b90ac098f0e0677d3c32e", @@ -17954,20 +17958,20 @@ "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/docker-compose.yaml": "98fd175c631ec5f61fa451139d6791d336627550928a835b3a5599b9e19dbbcc", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/team/scenario/episode.yaml": "a1a3173f2f7b2a2d3e4929f00292279a65c8403160f6fef0c7a534598a8d95de", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/team/scenario/notes.md": "6fc0439da0df692dc22d960b4d303611eb18621a07515dac39c5f6aae8baa04e", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/team/scenario/prefill.json": "29c51a3deb04fe7632818fc669fa7047051683a1d612d926b3a688aae4422140", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/team/scenario/record.json": "9cd4f668dd0657d5b012c9618e0d5a9e0a82b18c895b90ac098f0e0677d3c32e", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/team/scenario/source.md": "919e0e88a35eeb85adfc6ebcf83977847a3a74307386b5b49d496ff060ba3d40", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/team/task.json": "5a9c62280222d11b22a68df645758fab4c9ea189f1828433d0a559e85784c182", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/team/task.json": "72f04e12ef2cc0efdc473309d6c60da4a5c6d1f570d82f73e17880680b660912", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -17980,13 +17984,13 @@ "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/task.toml": "6b3a9cdb1cd0b4e5b3bc872cf7e674859fee9650df9a1fcdf0c67e48032b2e64", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/task.toml": "ef1aca87f51b3c70c5011fa5ec74fac2079cfbb6bfb26f9c49b1cf05181d5d20", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/tests/expected.json": "423172e11d77f757e8d8d6d61c55c1d62433fdd0ebfbaa3409c6f330d0490d1d", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/tests/scenario/episode.yaml": "a1a3173f2f7b2a2d3e4929f00292279a65c8403160f6fef0c7a534598a8d95de", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/tests/scenario/notes.md": "6fc0439da0df692dc22d960b4d303611eb18621a07515dac39c5f6aae8baa04e", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/tests/scenario/prefill.json": "29c51a3deb04fe7632818fc669fa7047051683a1d612d926b3a688aae4422140", @@ -18006,20 +18010,20 @@ "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/docker-compose.yaml": "e420be4eb0174b9eaeb1856906af596614f8bfef88d5af0108877b0864ca9112", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/team/scenario/episode.yaml": "a1a3173f2f7b2a2d3e4929f00292279a65c8403160f6fef0c7a534598a8d95de", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/team/scenario/notes.md": "6fc0439da0df692dc22d960b4d303611eb18621a07515dac39c5f6aae8baa04e", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/team/scenario/prefill.json": "29c51a3deb04fe7632818fc669fa7047051683a1d612d926b3a688aae4422140", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/team/scenario/record.json": "9cd4f668dd0657d5b012c9618e0d5a9e0a82b18c895b90ac098f0e0677d3c32e", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/team/scenario/source.md": "919e0e88a35eeb85adfc6ebcf83977847a3a74307386b5b49d496ff060ba3d40", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/team/task.json": "faeea3766d8539d44ba1cf50871dbb70250d7a5e0e40c514af8a7ea01048bbdc", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/team/task.json": "c65fdd661e5cf52b2e084c51201f1802b9475b68d12f614398b1b9d512369bf3", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -18032,13 +18036,13 @@ "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/task.toml": "f0843024ebdcc8a30f1f292f715e52e08b60bc7cfa4eb661d926663e653a8076", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/task.toml": "5dd544f1aa1e6421b862b731008ac7889934088a2994e23c2023701fe804d84c", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/tests/expected.json": "5d999bd8f69001f5319daf413adc8acaa054e14c3680644c3de0c9797250a901", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/tests/scenario/episode.yaml": "a1a3173f2f7b2a2d3e4929f00292279a65c8403160f6fef0c7a534598a8d95de", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/tests/scenario/notes.md": "6fc0439da0df692dc22d960b4d303611eb18621a07515dac39c5f6aae8baa04e", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/tests/scenario/prefill.json": "29c51a3deb04fe7632818fc669fa7047051683a1d612d926b3a688aae4422140", @@ -18058,20 +18062,20 @@ "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/agent/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/agent/team": "7526f8ccae4b1f3632b960cf0d63aab7e7a81f0726bcfb62c559743898575a4a", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/docker-compose.yaml": "af7e10b7229d80fa3ec797a286d6fd730e4664658d46c536dd3867525dd0cd80", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/model-compat/Dockerfile": "f44ff3125bd4d7566460780c84c320594f9a6b34e4f3d461907dacca1b188c65", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/model-compat/compatibility.json": "36b67dd52b01e15c89180b713e875a9fd31a3a3a5edcc063e8d0ea12a03716ca", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/model-compat/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/model-compat/Dockerfile": "fd488388f5043532ddc73efdef3dbd020885ef235917fb88330ec5fe27b53ce5", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/model-compat/compatibility.json": "ba3b1a22294c869ab611b7e6f74d2b76a468c4058fc0b99bc50ef6e20bb127d8", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/model-compat/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/team/Dockerfile": "b5f405a001d3729d0bac093a88d6f2daff475568841f6b920d11cc02f3ceadc0", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/team/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/team/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/team/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/team/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/team/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/team/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/team/scenario/episode.yaml": "a1a3173f2f7b2a2d3e4929f00292279a65c8403160f6fef0c7a534598a8d95de", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/team/scenario/notes.md": "6fc0439da0df692dc22d960b4d303611eb18621a07515dac39c5f6aae8baa04e", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/team/scenario/prefill.json": "29c51a3deb04fe7632818fc669fa7047051683a1d612d926b3a688aae4422140", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/team/scenario/record.json": "9cd4f668dd0657d5b012c9618e0d5a9e0a82b18c895b90ac098f0e0677d3c32e", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/team/scenario/source.md": "919e0e88a35eeb85adfc6ebcf83977847a3a74307386b5b49d496ff060ba3d40", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/team/task.json": "a7e6d0953ce6865ae6e2695eb8f83e3dd1c1251f00c3c9f4dee6a74fbc38045c", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/team/task.json": "466e52b45234b7f563944d86d2b8b4b6b42f0501d0359d987ca701594e534523", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/worker/Dockerfile": "994812bb38a03c1eb1beb7b6643df4aae270b8f136b85faf2845d4f6376cc780", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/worker/coding.py": "4cf6ec3e76d263c5d4557511ba95e1dda4856dfa5bd883b1610705fa8dfde4be", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/worker/collab_intel/__init__.py": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855", @@ -18084,13 +18088,13 @@ "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/solution/oracle.py": "6461c44cae7ae259dcdd9dce2f819916f660c824534b09fcd6b7fd33eb7e32a4", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/solution/solve.sh": "254b3fb0272756acfb7b99febf15e8740023ad00f5b119d039aa88ef4a0d132c", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/source-lock.json": "06a1de68cbc887e4e4b51fca9e43fee98f722b09d73777bdfd739446f8354ac3", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/task.toml": "219261005a638e12285641a709cec70ddd7df7333ee7c900ac880b5ee26083bb", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/task.toml": "7cddde5faef861ae6b040f6c3d8a5aa3c4420da0ade2efa4c3299b88482adf54", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/tests/Dockerfile": "bef4a5191ef3367bc7a56af96dab8a8b3abb766630efcac0eded9a6e22426519", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/tests/expected.json": "142660ff862090393c25e4ebef8cd870113068f2acbb68b37768d4bc029c0d70", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/tests/requirements.txt": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/tests/runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/tests/runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/tests/runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/tests/runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/tests/runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/tests/scenario/episode.yaml": "a1a3173f2f7b2a2d3e4929f00292279a65c8403160f6fef0c7a534598a8d95de", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/tests/scenario/notes.md": "6fc0439da0df692dc22d960b4d303611eb18621a07515dac39c5f6aae8baa04e", "tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/tests/scenario/prefill.json": "29c51a3deb04fe7632818fc669fa7047051683a1d612d926b3a688aae4422140", diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/Dockerfile b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/Dockerfile index a3b70c6bc89afece994c29d00a170866b8613806..94aa12bd481e74988451e2982dd1af085dea3e96 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/Dockerfile +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/Dockerfile @@ -1,5 +1,5 @@ FROM python:3.13-slim-bookworm@sha256:281d39ff02e3b389401586134ff9e6572954687822a58055ec07a60ded4e0b7f -COPY google_compat.py /app/google_compat.py -RUN chmod 644 /app/google_compat.py +COPY model_gateway.py /app/model_gateway.py +RUN chmod 644 /app/model_gateway.py USER 65534:65534 -ENTRYPOINT ["python", "-B", "/app/google_compat.py"] +ENTRYPOINT ["python", "-B", "/app/model_gateway.py"] diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/compatibility.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/compatibility.json index b4dd079fb5f4c07a63a11dc4e3cda203a0adad9a..8d3b92c6ad226a57604a74d9fb00a53f605c8b2f 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/compatibility.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/compatibility.json @@ -17,5 +17,5 @@ "model-compat" ], "agent_main_explicit_networks": false, - "source_sha256": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b" + "source_sha256": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78" } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/model_gateway.py similarity index 93% rename from tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/google_compat.py rename to tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/model_gateway.py index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..96dc58b5e6e763197a75c1a95aaec45159dbc864 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/google_compat.py +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/model-compat/model_gateway.py @@ -22,8 +22,10 @@ unchanged except as noted, to one configured upstream: anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider would fetch them on the agent's behalf. URLs inside plain text are not fetched. * ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). + not send; only ``anthropic-workspace-id``, ``openai-organization``, + ``openai-project`` and ``x-hf-bill-to`` are accepted (an unscoped Anthropic key + needs the first). ``x-hf-bill-to`` (Hugging Face org billing) is operator-only: + a caller's own copy is removed and only the configured value is sent. * A streamed request whose provider is slow (more than 3 s) is answered with a 200 event stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): @@ -32,7 +34,7 @@ unchanged except as noted, to one configured upstream: No credentials are owned or stored (the caller's auth headers pass through), no content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. +ambiguous. """ from __future__ import annotations @@ -56,7 +58,10 @@ ROUTES = { "/v1/responses": "/responses", "/v1/messages": "/messages", } -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} +ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project", "x-hf-bill-to"} +# Set only by the operator (CI_MODEL_HEADERS): a caller's own copy is always removed, so the agent cannot choose +# which organization is billed. +OPERATOR_ONLY_HEADERS = {"x-hf-bill-to"} MAX_BODY = 32 * 1024 * 1024 # Request fields that make the provider fetch or run things server-side. SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} @@ -197,10 +202,15 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N self.wfile.write(b'{"ok":true}') def do_POST(self): - target = ROUTES.get(self.path) + # Route on the path; a query string (the Anthropic SDK's beta client sends /v1/messages?beta=true) + # is forwarded to the provider unchanged. + request_url = urlsplit(self.path) + route = request_url.path + target = ROUTES.get(route) if target is None: self.send_error(404) return + forwarded_path = base_path + target + ("?" + request_url.query if request_url.query else "") try: if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): raise ValueError("A complete JSON Content-Length body is required") @@ -208,7 +218,7 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N if not 0 < length <= MAX_BODY: raise ValueError("Request body size out of bounds") incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) + outgoing = compatible_body(incoming, upstream, path=route, model=model) payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() except (ValueError, TypeError): self.send_error(400, "Unsupported model gateway request") @@ -221,7 +231,8 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N connection = ( http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} + headers = {key: value for key, value in self.headers.items() + if key.lower() not in HOP_BY_HOP and key.lower() not in OPERATOR_ONLY_HEADERS} sent = {key.lower() for key in headers} headers.update({key: value for key, value in extra_headers.items() if key not in sent}) headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", @@ -245,7 +256,7 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N provider_sock["sock"] = connection.sock if provider_sock.get("aborted"): raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) + connection.request("POST", forwarded_path, payload, headers) result["response"] = connection.getresponse() except (OSError, http.client.HTTPException) as error: result["error"] = error @@ -324,7 +335,7 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N if response is not None and response.status == 200 and encoding != "identity": # Our headers are already sent without Content-Encoding: never relay bytes the caller # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " + self.wfile.write(stream_error(route, f"Upstream sent Content-Encoding {encoding!r} " "despite Accept-Encoding: identity", 502)) self.wfile.flush() self.close_connection = True @@ -334,7 +345,7 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" message = (f"Upstream HTTP {status}: {detail}" if response is not None else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) + self.wfile.write(stream_error(route, message, status)) self.wfile.flush() self.close_connection = True return diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/runtime.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/runtime.json index 5c05ecbbe8bf062dc777b55f6cb09d28c0ea6386..d999eb266c151fd59ccf39757c70d3be299bbff5 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/runtime.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "archive_sha256": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -9,31 +9,32 @@ "adapter/collab_harbor/command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "adapter/collab_harbor/compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "adapter/collab_harbor/continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "adapter/collab_harbor/dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "adapter/collab_harbor/export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "adapter/collab_harbor/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/collab_harbor/flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "adapter/collab_harbor/flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "adapter/collab_harbor/generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "adapter/collab_harbor/grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "adapter/collab_harbor/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "adapter/collab_harbor/model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "adapter/collab_harbor/pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "adapter/collab_harbor/pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "adapter/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "adapter/collab_harbor/pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "adapter/collab_harbor/pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "adapter/collab_harbor/private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "adapter/collab_harbor/private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "adapter/collab_harbor/provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "adapter/collab_harbor/pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "adapter/collab_harbor/reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "adapter/collab_harbor/replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "adapter/collab_harbor/run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", - "adapter/collab_harbor/runtime-files.json": "675382b88a6dd8dd23b8825a7017af26d6d0c900c4f6dc6f0ecbd88aea9d0354", + "adapter/collab_harbor/run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", + "adapter/collab_harbor/runtime-files.json": "2c91e60ab99be36ae8b28cd1aaa23a2b3b5be4193287f787507f8b3fa7a40726", "adapter/collab_harbor/runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "adapter/collab_harbor/scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "adapter/collab_harbor/service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "adapter/collab_harbor/scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "adapter/collab_harbor/service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "adapter/collab_harbor/sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "adapter/collab_harbor/stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "adapter/collab_harbor/takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/collab_harbor/takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "adapter/collab_harbor/vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "adapter/collab_harbor/workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8", "upstream/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -99,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1472807, + "uncompressed_bytes": 1475357, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/runtime.tar.gz b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/runtime.tar.gz index 57436434d48ab3d4c29df74e3d542be7d0b25451..f74033c23a84d62b55e8967d2a1521b6d9e52653 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/runtime.tar.gz +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1 -size 392924 +oid sha256:d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6 +size 393898 diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/task.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/task.json index b76f549c117d9b821595af7ea5305e4f812b3a87..ad78db0a2fc3a027463016f40e95853f788cb115 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/task.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/environment/team/task.json @@ -56,34 +56,35 @@ "command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", + "run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", "runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "0b48c4938c9a4e7cdb23a3146908442f6f0c6c986359b88cc6d5a04b15f5eceb" + "sha256": "fcb79c83102403397f7c05d3d991ba64ea673de9d2b6590ead92de24f2159515" }, "verifier_adapter": { "schema_version": 1, @@ -95,34 +96,35 @@ "command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", + "run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", "runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "0b48c4938c9a4e7cdb23a3146908442f6f0c6c986359b88cc6d5a04b15f5eceb" + "sha256": "fcb79c83102403397f7c05d3d991ba64ea673de9d2b6590ead92de24f2159515" }, "team_upstream": { "schema_version": 1, @@ -248,26 +250,26 @@ "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1" + "runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6" }, - "sha256": "1fd45d5914f5f155eafafb0b47004e37e96fcc4de63db16762bebb89d8bb2014" + "sha256": "a03d87d987a703bbfbe6ca5b05ce2f489745dd956de2df32fc9b9effd9dba42b" }, "verifier_runtime_distribution": { "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1" + "runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6" }, - "sha256": "1fd45d5914f5f155eafafb0b47004e37e96fcc4de63db16762bebb89d8bb2014" + "sha256": "a03d87d987a703bbfbe6ca5b05ce2f489745dd956de2df32fc9b9effd9dba42b" }, "runtime_distribution": { "schema_version": 1, "files": { - "runtime-distribution.json": "86a364434305d761e9a9249b6cfcf0ab649d3bd6eb084c112068c65ac1a89817" + "runtime-distribution.json": "534865bee3118019fc3284e1de6841fff5d85b8f1f65b7038ef4539baf77993d" }, - "sha256": "f4a7684277c4d2ccf2ed76b054a17f2ffc301c220078ab7c2fcc3aedadd0f6d7" + "sha256": "6b39152523a378b895a53f8e0cf9e93af51b9e6a9b33532f19a062595a30fc4e" }, "environment_policy": { "schema_version": 1, @@ -313,10 +315,10 @@ "sha256": "33b10cc4a7d760c70a490b186618d63dd730389503da1396eec47afc8b436d60" } }, - "sha256": "90b62628993f8b79032c658668d3749a58c27fe319b86f58dfc39e62b6638e04" + "sha256": "4c3396773ae0306b5d5aded5d5d6b7955971ae3cbe7fb0f1a06f915f96a43598" }, "runtime_distribution": { "format": "ci-private-runtime-tar-gzip-v1", - "archive_sha256": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1" + "archive_sha256": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6" } } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/task.toml b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/task.toml index 0404eafbe9be76ecf5aded7de08cc8a35f95e42f..7497da50137dcd087fa767e874a2894940f50dbf 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/task.toml +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/task.toml @@ -36,5 +36,5 @@ timeout_sec = 150 [[verifier.collect]] service = "team" -command = "python -m collab_harbor.export" +command = "python -m collab_harbor.export_evidence" timeout_sec = 86400 diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/runtime.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/runtime.json index 5c05ecbbe8bf062dc777b55f6cb09d28c0ea6386..d999eb266c151fd59ccf39757c70d3be299bbff5 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/runtime.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "archive_sha256": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -9,31 +9,32 @@ "adapter/collab_harbor/command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "adapter/collab_harbor/compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "adapter/collab_harbor/continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "adapter/collab_harbor/dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "adapter/collab_harbor/export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "adapter/collab_harbor/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/collab_harbor/flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "adapter/collab_harbor/flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "adapter/collab_harbor/generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "adapter/collab_harbor/grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "adapter/collab_harbor/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "adapter/collab_harbor/model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "adapter/collab_harbor/pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "adapter/collab_harbor/pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "adapter/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "adapter/collab_harbor/pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "adapter/collab_harbor/pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "adapter/collab_harbor/private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "adapter/collab_harbor/private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "adapter/collab_harbor/provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "adapter/collab_harbor/pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "adapter/collab_harbor/reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "adapter/collab_harbor/replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "adapter/collab_harbor/run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", - "adapter/collab_harbor/runtime-files.json": "675382b88a6dd8dd23b8825a7017af26d6d0c900c4f6dc6f0ecbd88aea9d0354", + "adapter/collab_harbor/run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", + "adapter/collab_harbor/runtime-files.json": "2c91e60ab99be36ae8b28cd1aaa23a2b3b5be4193287f787507f8b3fa7a40726", "adapter/collab_harbor/runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "adapter/collab_harbor/scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "adapter/collab_harbor/service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "adapter/collab_harbor/scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "adapter/collab_harbor/service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "adapter/collab_harbor/sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "adapter/collab_harbor/stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "adapter/collab_harbor/takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/collab_harbor/takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "adapter/collab_harbor/vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "adapter/collab_harbor/workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8", "upstream/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -99,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1472807, + "uncompressed_bytes": 1475357, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/runtime.tar.gz b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/runtime.tar.gz index 57436434d48ab3d4c29df74e3d542be7d0b25451..f74033c23a84d62b55e8967d2a1521b6d9e52653 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/runtime.tar.gz +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-baseline-s0/tests/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1 -size 392924 +oid sha256:d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6 +size 393898 diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/Dockerfile b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/Dockerfile index a3b70c6bc89afece994c29d00a170866b8613806..94aa12bd481e74988451e2982dd1af085dea3e96 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/Dockerfile +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/Dockerfile @@ -1,5 +1,5 @@ FROM python:3.13-slim-bookworm@sha256:281d39ff02e3b389401586134ff9e6572954687822a58055ec07a60ded4e0b7f -COPY google_compat.py /app/google_compat.py -RUN chmod 644 /app/google_compat.py +COPY model_gateway.py /app/model_gateway.py +RUN chmod 644 /app/model_gateway.py USER 65534:65534 -ENTRYPOINT ["python", "-B", "/app/google_compat.py"] +ENTRYPOINT ["python", "-B", "/app/model_gateway.py"] diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/compatibility.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/compatibility.json index b4dd079fb5f4c07a63a11dc4e3cda203a0adad9a..8d3b92c6ad226a57604a74d9fb00a53f605c8b2f 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/compatibility.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/compatibility.json @@ -17,5 +17,5 @@ "model-compat" ], "agent_main_explicit_networks": false, - "source_sha256": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b" + "source_sha256": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78" } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/model_gateway.py similarity index 93% rename from tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/google_compat.py rename to tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/model_gateway.py index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..96dc58b5e6e763197a75c1a95aaec45159dbc864 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/google_compat.py +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/model-compat/model_gateway.py @@ -22,8 +22,10 @@ unchanged except as noted, to one configured upstream: anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider would fetch them on the agent's behalf. URLs inside plain text are not fetched. * ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). + not send; only ``anthropic-workspace-id``, ``openai-organization``, + ``openai-project`` and ``x-hf-bill-to`` are accepted (an unscoped Anthropic key + needs the first). ``x-hf-bill-to`` (Hugging Face org billing) is operator-only: + a caller's own copy is removed and only the configured value is sent. * A streamed request whose provider is slow (more than 3 s) is answered with a 200 event stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): @@ -32,7 +34,7 @@ unchanged except as noted, to one configured upstream: No credentials are owned or stored (the caller's auth headers pass through), no content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. +ambiguous. """ from __future__ import annotations @@ -56,7 +58,10 @@ ROUTES = { "/v1/responses": "/responses", "/v1/messages": "/messages", } -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} +ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project", "x-hf-bill-to"} +# Set only by the operator (CI_MODEL_HEADERS): a caller's own copy is always removed, so the agent cannot choose +# which organization is billed. +OPERATOR_ONLY_HEADERS = {"x-hf-bill-to"} MAX_BODY = 32 * 1024 * 1024 # Request fields that make the provider fetch or run things server-side. SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} @@ -197,10 +202,15 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N self.wfile.write(b'{"ok":true}') def do_POST(self): - target = ROUTES.get(self.path) + # Route on the path; a query string (the Anthropic SDK's beta client sends /v1/messages?beta=true) + # is forwarded to the provider unchanged. + request_url = urlsplit(self.path) + route = request_url.path + target = ROUTES.get(route) if target is None: self.send_error(404) return + forwarded_path = base_path + target + ("?" + request_url.query if request_url.query else "") try: if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): raise ValueError("A complete JSON Content-Length body is required") @@ -208,7 +218,7 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N if not 0 < length <= MAX_BODY: raise ValueError("Request body size out of bounds") incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) + outgoing = compatible_body(incoming, upstream, path=route, model=model) payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() except (ValueError, TypeError): self.send_error(400, "Unsupported model gateway request") @@ -221,7 +231,8 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N connection = ( http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} + headers = {key: value for key, value in self.headers.items() + if key.lower() not in HOP_BY_HOP and key.lower() not in OPERATOR_ONLY_HEADERS} sent = {key.lower() for key in headers} headers.update({key: value for key, value in extra_headers.items() if key not in sent}) headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", @@ -245,7 +256,7 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N provider_sock["sock"] = connection.sock if provider_sock.get("aborted"): raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) + connection.request("POST", forwarded_path, payload, headers) result["response"] = connection.getresponse() except (OSError, http.client.HTTPException) as error: result["error"] = error @@ -324,7 +335,7 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N if response is not None and response.status == 200 and encoding != "identity": # Our headers are already sent without Content-Encoding: never relay bytes the caller # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " + self.wfile.write(stream_error(route, f"Upstream sent Content-Encoding {encoding!r} " "despite Accept-Encoding: identity", 502)) self.wfile.flush() self.close_connection = True @@ -334,7 +345,7 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" message = (f"Upstream HTTP {status}: {detail}" if response is not None else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) + self.wfile.write(stream_error(route, message, status)) self.wfile.flush() self.close_connection = True return diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/runtime.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/runtime.json index 5c05ecbbe8bf062dc777b55f6cb09d28c0ea6386..d999eb266c151fd59ccf39757c70d3be299bbff5 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/runtime.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "archive_sha256": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -9,31 +9,32 @@ "adapter/collab_harbor/command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "adapter/collab_harbor/compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "adapter/collab_harbor/continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "adapter/collab_harbor/dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "adapter/collab_harbor/export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "adapter/collab_harbor/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/collab_harbor/flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "adapter/collab_harbor/flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "adapter/collab_harbor/generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "adapter/collab_harbor/grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "adapter/collab_harbor/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "adapter/collab_harbor/model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "adapter/collab_harbor/pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "adapter/collab_harbor/pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "adapter/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "adapter/collab_harbor/pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "adapter/collab_harbor/pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "adapter/collab_harbor/private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "adapter/collab_harbor/private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "adapter/collab_harbor/provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "adapter/collab_harbor/pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "adapter/collab_harbor/reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "adapter/collab_harbor/replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "adapter/collab_harbor/run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", - "adapter/collab_harbor/runtime-files.json": "675382b88a6dd8dd23b8825a7017af26d6d0c900c4f6dc6f0ecbd88aea9d0354", + "adapter/collab_harbor/run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", + "adapter/collab_harbor/runtime-files.json": "2c91e60ab99be36ae8b28cd1aaa23a2b3b5be4193287f787507f8b3fa7a40726", "adapter/collab_harbor/runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "adapter/collab_harbor/scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "adapter/collab_harbor/service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "adapter/collab_harbor/scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "adapter/collab_harbor/service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "adapter/collab_harbor/sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "adapter/collab_harbor/stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "adapter/collab_harbor/takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/collab_harbor/takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "adapter/collab_harbor/vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "adapter/collab_harbor/workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8", "upstream/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -99,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1472807, + "uncompressed_bytes": 1475357, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/runtime.tar.gz b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/runtime.tar.gz index 57436434d48ab3d4c29df74e3d542be7d0b25451..f74033c23a84d62b55e8967d2a1521b6d9e52653 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/runtime.tar.gz +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1 -size 392924 +oid sha256:d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6 +size 393898 diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/task.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/task.json index 49a716f738bf7dd0c4f3cb8ee65c64a76355b9ee..4f88d3a541fd273c6fcf66396b4d022d4d905e52 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/task.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/environment/team/task.json @@ -56,34 +56,35 @@ "command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", + "run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", "runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "0b48c4938c9a4e7cdb23a3146908442f6f0c6c986359b88cc6d5a04b15f5eceb" + "sha256": "fcb79c83102403397f7c05d3d991ba64ea673de9d2b6590ead92de24f2159515" }, "verifier_adapter": { "schema_version": 1, @@ -95,34 +96,35 @@ "command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", + "run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", "runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "0b48c4938c9a4e7cdb23a3146908442f6f0c6c986359b88cc6d5a04b15f5eceb" + "sha256": "fcb79c83102403397f7c05d3d991ba64ea673de9d2b6590ead92de24f2159515" }, "team_upstream": { "schema_version": 1, @@ -248,26 +250,26 @@ "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1" + "runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6" }, - "sha256": "1fd45d5914f5f155eafafb0b47004e37e96fcc4de63db16762bebb89d8bb2014" + "sha256": "a03d87d987a703bbfbe6ca5b05ce2f489745dd956de2df32fc9b9effd9dba42b" }, "verifier_runtime_distribution": { "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1" + "runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6" }, - "sha256": "1fd45d5914f5f155eafafb0b47004e37e96fcc4de63db16762bebb89d8bb2014" + "sha256": "a03d87d987a703bbfbe6ca5b05ce2f489745dd956de2df32fc9b9effd9dba42b" }, "runtime_distribution": { "schema_version": 1, "files": { - "runtime-distribution.json": "86a364434305d761e9a9249b6cfcf0ab649d3bd6eb084c112068c65ac1a89817" + "runtime-distribution.json": "534865bee3118019fc3284e1de6841fff5d85b8f1f65b7038ef4539baf77993d" }, - "sha256": "f4a7684277c4d2ccf2ed76b054a17f2ffc301c220078ab7c2fcc3aedadd0f6d7" + "sha256": "6b39152523a378b895a53f8e0cf9e93af51b9e6a9b33532f19a062595a30fc4e" }, "environment_policy": { "schema_version": 1, @@ -313,10 +315,10 @@ "sha256": "33b10cc4a7d760c70a490b186618d63dd730389503da1396eec47afc8b436d60" } }, - "sha256": "d4ba7e52e4881cebf1f01ba2f6d6cee4753b5e2a3b361cddd8463aaf7574ca38" + "sha256": "a3980d3aea5a0009e5ccf05ea0b433b5b385659f6d6f033e820764c04db1b525" }, "runtime_distribution": { "format": "ci-private-runtime-tar-gzip-v1", - "archive_sha256": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1" + "archive_sha256": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6" } } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/task.toml b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/task.toml index af1634326359f37cce9c055907dd8a48729b82f1..6a3cb00f2c80146747a68773f4b1655cd6967577 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/task.toml +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/task.toml @@ -36,5 +36,5 @@ timeout_sec = 150 [[verifier.collect]] service = "team" -command = "python -m collab_harbor.export" +command = "python -m collab_harbor.export_evidence" timeout_sec = 86400 diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/runtime.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/runtime.json index 5c05ecbbe8bf062dc777b55f6cb09d28c0ea6386..d999eb266c151fd59ccf39757c70d3be299bbff5 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/runtime.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "archive_sha256": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -9,31 +9,32 @@ "adapter/collab_harbor/command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "adapter/collab_harbor/compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "adapter/collab_harbor/continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "adapter/collab_harbor/dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "adapter/collab_harbor/export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "adapter/collab_harbor/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/collab_harbor/flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "adapter/collab_harbor/flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "adapter/collab_harbor/generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "adapter/collab_harbor/grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "adapter/collab_harbor/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "adapter/collab_harbor/model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "adapter/collab_harbor/pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "adapter/collab_harbor/pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "adapter/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "adapter/collab_harbor/pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "adapter/collab_harbor/pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "adapter/collab_harbor/private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "adapter/collab_harbor/private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "adapter/collab_harbor/provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "adapter/collab_harbor/pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "adapter/collab_harbor/reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "adapter/collab_harbor/replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "adapter/collab_harbor/run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", - "adapter/collab_harbor/runtime-files.json": "675382b88a6dd8dd23b8825a7017af26d6d0c900c4f6dc6f0ecbd88aea9d0354", + "adapter/collab_harbor/run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", + "adapter/collab_harbor/runtime-files.json": "2c91e60ab99be36ae8b28cd1aaa23a2b3b5be4193287f787507f8b3fa7a40726", "adapter/collab_harbor/runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "adapter/collab_harbor/scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "adapter/collab_harbor/service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "adapter/collab_harbor/scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "adapter/collab_harbor/service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "adapter/collab_harbor/sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "adapter/collab_harbor/stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "adapter/collab_harbor/takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/collab_harbor/takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "adapter/collab_harbor/vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "adapter/collab_harbor/workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8", "upstream/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -99,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1472807, + "uncompressed_bytes": 1475357, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/runtime.tar.gz b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/runtime.tar.gz index 57436434d48ab3d4c29df74e3d542be7d0b25451..f74033c23a84d62b55e8967d2a1521b6d9e52653 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/runtime.tar.gz +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-solo-s0/tests/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1 -size 392924 +oid sha256:d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6 +size 393898 diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/Dockerfile b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/Dockerfile index a3b70c6bc89afece994c29d00a170866b8613806..94aa12bd481e74988451e2982dd1af085dea3e96 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/Dockerfile +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/Dockerfile @@ -1,5 +1,5 @@ FROM python:3.13-slim-bookworm@sha256:281d39ff02e3b389401586134ff9e6572954687822a58055ec07a60ded4e0b7f -COPY google_compat.py /app/google_compat.py -RUN chmod 644 /app/google_compat.py +COPY model_gateway.py /app/model_gateway.py +RUN chmod 644 /app/model_gateway.py USER 65534:65534 -ENTRYPOINT ["python", "-B", "/app/google_compat.py"] +ENTRYPOINT ["python", "-B", "/app/model_gateway.py"] diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/compatibility.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/compatibility.json index b4dd079fb5f4c07a63a11dc4e3cda203a0adad9a..8d3b92c6ad226a57604a74d9fb00a53f605c8b2f 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/compatibility.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/compatibility.json @@ -17,5 +17,5 @@ "model-compat" ], "agent_main_explicit_networks": false, - "source_sha256": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b" + "source_sha256": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78" } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/model_gateway.py similarity index 93% rename from tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/google_compat.py rename to tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/model_gateway.py index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..96dc58b5e6e763197a75c1a95aaec45159dbc864 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/google_compat.py +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/model-compat/model_gateway.py @@ -22,8 +22,10 @@ unchanged except as noted, to one configured upstream: anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider would fetch them on the agent's behalf. URLs inside plain text are not fetched. * ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). + not send; only ``anthropic-workspace-id``, ``openai-organization``, + ``openai-project`` and ``x-hf-bill-to`` are accepted (an unscoped Anthropic key + needs the first). ``x-hf-bill-to`` (Hugging Face org billing) is operator-only: + a caller's own copy is removed and only the configured value is sent. * A streamed request whose provider is slow (more than 3 s) is answered with a 200 event stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): @@ -32,7 +34,7 @@ unchanged except as noted, to one configured upstream: No credentials are owned or stored (the caller's auth headers pass through), no content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. +ambiguous. """ from __future__ import annotations @@ -56,7 +58,10 @@ ROUTES = { "/v1/responses": "/responses", "/v1/messages": "/messages", } -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} +ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project", "x-hf-bill-to"} +# Set only by the operator (CI_MODEL_HEADERS): a caller's own copy is always removed, so the agent cannot choose +# which organization is billed. +OPERATOR_ONLY_HEADERS = {"x-hf-bill-to"} MAX_BODY = 32 * 1024 * 1024 # Request fields that make the provider fetch or run things server-side. SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} @@ -197,10 +202,15 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N self.wfile.write(b'{"ok":true}') def do_POST(self): - target = ROUTES.get(self.path) + # Route on the path; a query string (the Anthropic SDK's beta client sends /v1/messages?beta=true) + # is forwarded to the provider unchanged. + request_url = urlsplit(self.path) + route = request_url.path + target = ROUTES.get(route) if target is None: self.send_error(404) return + forwarded_path = base_path + target + ("?" + request_url.query if request_url.query else "") try: if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): raise ValueError("A complete JSON Content-Length body is required") @@ -208,7 +218,7 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N if not 0 < length <= MAX_BODY: raise ValueError("Request body size out of bounds") incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) + outgoing = compatible_body(incoming, upstream, path=route, model=model) payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() except (ValueError, TypeError): self.send_error(400, "Unsupported model gateway request") @@ -221,7 +231,8 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N connection = ( http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} + headers = {key: value for key, value in self.headers.items() + if key.lower() not in HOP_BY_HOP and key.lower() not in OPERATOR_ONLY_HEADERS} sent = {key.lower() for key in headers} headers.update({key: value for key, value in extra_headers.items() if key not in sent}) headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", @@ -245,7 +256,7 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N provider_sock["sock"] = connection.sock if provider_sock.get("aborted"): raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) + connection.request("POST", forwarded_path, payload, headers) result["response"] = connection.getresponse() except (OSError, http.client.HTTPException) as error: result["error"] = error @@ -324,7 +335,7 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N if response is not None and response.status == 200 and encoding != "identity": # Our headers are already sent without Content-Encoding: never relay bytes the caller # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " + self.wfile.write(stream_error(route, f"Upstream sent Content-Encoding {encoding!r} " "despite Accept-Encoding: identity", 502)) self.wfile.flush() self.close_connection = True @@ -334,7 +345,7 @@ def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=N detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" message = (f"Upstream HTTP {status}: {detail}" if response is not None else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) + self.wfile.write(stream_error(route, message, status)) self.wfile.flush() self.close_connection = True return diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/runtime.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/runtime.json index 5c05ecbbe8bf062dc777b55f6cb09d28c0ea6386..d999eb266c151fd59ccf39757c70d3be299bbff5 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/runtime.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "archive_sha256": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -9,31 +9,32 @@ "adapter/collab_harbor/command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "adapter/collab_harbor/compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "adapter/collab_harbor/continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "adapter/collab_harbor/dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "adapter/collab_harbor/export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "adapter/collab_harbor/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/collab_harbor/flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "adapter/collab_harbor/flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "adapter/collab_harbor/generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "adapter/collab_harbor/grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "adapter/collab_harbor/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "adapter/collab_harbor/model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "adapter/collab_harbor/pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "adapter/collab_harbor/pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "adapter/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "adapter/collab_harbor/pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "adapter/collab_harbor/pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "adapter/collab_harbor/private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "adapter/collab_harbor/private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "adapter/collab_harbor/provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "adapter/collab_harbor/pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "adapter/collab_harbor/reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "adapter/collab_harbor/replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "adapter/collab_harbor/run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", - "adapter/collab_harbor/runtime-files.json": "675382b88a6dd8dd23b8825a7017af26d6d0c900c4f6dc6f0ecbd88aea9d0354", + "adapter/collab_harbor/run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", + "adapter/collab_harbor/runtime-files.json": "2c91e60ab99be36ae8b28cd1aaa23a2b3b5be4193287f787507f8b3fa7a40726", "adapter/collab_harbor/runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "adapter/collab_harbor/scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "adapter/collab_harbor/service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "adapter/collab_harbor/scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "adapter/collab_harbor/service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "adapter/collab_harbor/sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "adapter/collab_harbor/stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "adapter/collab_harbor/takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/collab_harbor/takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "adapter/collab_harbor/vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "adapter/collab_harbor/workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8", "upstream/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -99,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1472807, + "uncompressed_bytes": 1475357, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/runtime.tar.gz b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/runtime.tar.gz index 57436434d48ab3d4c29df74e3d542be7d0b25451..f74033c23a84d62b55e8967d2a1521b6d9e52653 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/runtime.tar.gz +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1 -size 392924 +oid sha256:d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6 +size 393898 diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/task.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/task.json index 6902b299de1f88392b523c7b33f26c996a6d4d81..21ab2278a62e3c589f6fd281967460256a7afafb 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/task.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/environment/team/task.json @@ -56,34 +56,35 @@ "command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", + "run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", "runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "0b48c4938c9a4e7cdb23a3146908442f6f0c6c986359b88cc6d5a04b15f5eceb" + "sha256": "fcb79c83102403397f7c05d3d991ba64ea673de9d2b6590ead92de24f2159515" }, "verifier_adapter": { "schema_version": 1, @@ -95,34 +96,35 @@ "command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", + "run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", "runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "0b48c4938c9a4e7cdb23a3146908442f6f0c6c986359b88cc6d5a04b15f5eceb" + "sha256": "fcb79c83102403397f7c05d3d991ba64ea673de9d2b6590ead92de24f2159515" }, "team_upstream": { "schema_version": 1, @@ -248,26 +250,26 @@ "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1" + "runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6" }, - "sha256": "1fd45d5914f5f155eafafb0b47004e37e96fcc4de63db16762bebb89d8bb2014" + "sha256": "a03d87d987a703bbfbe6ca5b05ce2f489745dd956de2df32fc9b9effd9dba42b" }, "verifier_runtime_distribution": { "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1" + "runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6" }, - "sha256": "1fd45d5914f5f155eafafb0b47004e37e96fcc4de63db16762bebb89d8bb2014" + "sha256": "a03d87d987a703bbfbe6ca5b05ce2f489745dd956de2df32fc9b9effd9dba42b" }, "runtime_distribution": { "schema_version": 1, "files": { - "runtime-distribution.json": "86a364434305d761e9a9249b6cfcf0ab649d3bd6eb084c112068c65ac1a89817" + "runtime-distribution.json": "534865bee3118019fc3284e1de6841fff5d85b8f1f65b7038ef4539baf77993d" }, - "sha256": "f4a7684277c4d2ccf2ed76b054a17f2ffc301c220078ab7c2fcc3aedadd0f6d7" + "sha256": "6b39152523a378b895a53f8e0cf9e93af51b9e6a9b33532f19a062595a30fc4e" }, "environment_policy": { "schema_version": 1, @@ -313,10 +315,10 @@ "sha256": "33b10cc4a7d760c70a490b186618d63dd730389503da1396eec47afc8b436d60" } }, - "sha256": "5626ee71a7661c81f7bd27be7c718b5726ffc7725e25376b95b2ad3d99d377cf" + "sha256": "ea9f6a30956640e16cdc476f8544c0f285fabcbd5a4293f84970640ee3401b77" }, "runtime_distribution": { "format": "ci-private-runtime-tar-gzip-v1", - "archive_sha256": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1" + "archive_sha256": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6" } } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/task.toml b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/task.toml index faf42c166c3569e4aa6aaa0d6ceccdee0dc3ffb4..7ef7040cece92dfa6599d16f5d8cbe62fa014658 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/task.toml +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/task.toml @@ -36,5 +36,5 @@ timeout_sec = 150 [[verifier.collect]] service = "team" -command = "python -m collab_harbor.export" +command = "python -m collab_harbor.export_evidence" timeout_sec = 86400 diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/runtime.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/runtime.json index 5c05ecbbe8bf062dc777b55f6cb09d28c0ea6386..d999eb266c151fd59ccf39757c70d3be299bbff5 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/runtime.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "archive_sha256": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -9,31 +9,32 @@ "adapter/collab_harbor/command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "adapter/collab_harbor/compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "adapter/collab_harbor/continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "adapter/collab_harbor/dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "adapter/collab_harbor/export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "adapter/collab_harbor/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/collab_harbor/flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "adapter/collab_harbor/flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "adapter/collab_harbor/generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "adapter/collab_harbor/grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "adapter/collab_harbor/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "adapter/collab_harbor/model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "adapter/collab_harbor/pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "adapter/collab_harbor/pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "adapter/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "adapter/collab_harbor/pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "adapter/collab_harbor/pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "adapter/collab_harbor/private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "adapter/collab_harbor/private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "adapter/collab_harbor/provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "adapter/collab_harbor/pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "adapter/collab_harbor/reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "adapter/collab_harbor/replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "adapter/collab_harbor/run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", - "adapter/collab_harbor/runtime-files.json": "675382b88a6dd8dd23b8825a7017af26d6d0c900c4f6dc6f0ecbd88aea9d0354", + "adapter/collab_harbor/run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", + "adapter/collab_harbor/runtime-files.json": "2c91e60ab99be36ae8b28cd1aaa23a2b3b5be4193287f787507f8b3fa7a40726", "adapter/collab_harbor/runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "adapter/collab_harbor/scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "adapter/collab_harbor/service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "adapter/collab_harbor/scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "adapter/collab_harbor/service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "adapter/collab_harbor/sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "adapter/collab_harbor/stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "adapter/collab_harbor/takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/collab_harbor/takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "adapter/collab_harbor/vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "adapter/collab_harbor/workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8", "upstream/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -99,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1472807, + "uncompressed_bytes": 1475357, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/runtime.tar.gz b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/runtime.tar.gz index 57436434d48ab3d4c29df74e3d542be7d0b25451..f74033c23a84d62b55e8967d2a1521b6d9e52653 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/runtime.tar.gz +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s0/tests/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1 -size 392924 +oid sha256:d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6 +size 393898 diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/Dockerfile b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/Dockerfile index a3b70c6bc89afece994c29d00a170866b8613806..94aa12bd481e74988451e2982dd1af085dea3e96 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/Dockerfile +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/Dockerfile @@ -1,5 +1,5 @@ FROM python:3.13-slim-bookworm@sha256:281d39ff02e3b389401586134ff9e6572954687822a58055ec07a60ded4e0b7f -COPY google_compat.py /app/google_compat.py -RUN chmod 644 /app/google_compat.py +COPY model_gateway.py /app/model_gateway.py +RUN chmod 644 /app/model_gateway.py USER 65534:65534 -ENTRYPOINT ["python", "-B", "/app/google_compat.py"] +ENTRYPOINT ["python", "-B", "/app/model_gateway.py"] diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/compatibility.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/compatibility.json index b4dd079fb5f4c07a63a11dc4e3cda203a0adad9a..8d3b92c6ad226a57604a74d9fb00a53f605c8b2f 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/compatibility.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/compatibility.json @@ -17,5 +17,5 @@ "model-compat" ], "agent_main_explicit_networks": false, - "source_sha256": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b" + "source_sha256": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78" } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/model_gateway.py b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/model_gateway.py new file mode 100644 index 0000000000000000000000000000000000000000..96dc58b5e6e763197a75c1a95aaec45159dbc864 --- /dev/null +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/model-compat/model_gateway.py @@ -0,0 +1,383 @@ +"""Task-local model gateway: the evaluated agent's only route to its model provider. + +The agent container has no internet during its run (Harbor allowlist: team and +model-compat). Pi sends every model request here, and so does the team +service's private final-answer readout. The gateway forwards each request, +unchanged except as noted, to one configured upstream: + +* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the + provider base URL including its version prefix, e.g. + ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an + inference endpoint's ``https://.../v1``. +* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to + ``/chat/completions``, ``/responses`` and ``/messages``. +* The only body change: for Google's endpoint, drop the optional top-level + ``store`` field (also in Pi's internal compaction calls), which Google rejects. +* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so + the agent cannot use the gateway to reach a different model. +* Only client-executed function tools pass. Provider-side tools (web search, web + fetch, MCP, code containers) are rejected: they would let the agent reach the + internet through the provider despite the network allowlist. +* Remote content references are rejected too (``image_url``/``file_url``/... pointing + anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider + would fetch them on the agent's behalf. URLs inside plain text are not fetched. +* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did + not send; only ``anthropic-workspace-id``, ``openai-organization``, + ``openai-project`` and ``x-hf-bill-to`` are accepted (an unscoped Anthropic key + needs the first). ``x-hf-bill-to`` (Hugging Face org billing) is operator-only: + a caller's own copy is removed and only the configured value is sent. + +* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event + stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): + Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway + always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). + +No credentials are owned or stored (the caller's auth headers pass through), no +content is logged, and nothing is retried: an ambiguous upstream attempt stays +ambiguous. +""" + +from __future__ import annotations + +import argparse +import http.client +import ipaddress +import json +import os +import select +import socket +import threading +import time +from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer +from urllib.parse import urlsplit + +GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" +GOOGLE_HOST = "generativelanguage.googleapis.com" +ROUTES = { + "/v1/chat/completions": "/chat/completions", + "/v1/responses": "/responses", + "/v1/messages": "/messages", +} +ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project", "x-hf-bill-to"} +# Set only by the operator (CI_MODEL_HEADERS): a caller's own copy is always removed, so the agent cannot choose +# which organization is billed. +OPERATOR_ONLY_HEADERS = {"x-hf-bill-to"} +MAX_BODY = 32 * 1024 * 1024 +# Request fields that make the provider fetch or run things server-side. +SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} +CLIENT_TOOL_TYPES = { + "/v1/chat/completions": {"function"}, + "/v1/responses": {"function", "custom"}, + "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") +} +REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} + + +def remote_reference(value): + """True if the request asks the provider to fetch content from a URL.""" + if isinstance(value, dict): + if value.get("type") == "url" and isinstance(value.get("url"), str): + return True # Anthropic image/document source + for key, item in value.items(): + if key in REMOTE_KEYS: + url = item.get("url") if isinstance(item, dict) else item + if isinstance(url, str) and not url.startswith("data:"): + return True + if remote_reference(item): + return True + elif isinstance(value, list): + return any(remote_reference(item) for item in value) + return False + + +# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays +# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER +# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds +# until the provider answers; the provider's stream is then relayed unchanged. A late provider +# error becomes the stream error event of that API. Fast answers (and all errors that arrive +# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. +STREAM_COMMIT_AFTER = 3.0 +STREAM_KEEPALIVE = 5.0 +CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected + + +def client_gone(sock): + """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" + try: + readable, _, _ = select.select([sock], [], [], 0) + return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" + except OSError: + return True + + +def stream_error(path, message, status=None): + """One SSE error event in the format the API's official SDK raises on.""" + if path == "/v1/messages": + body = {"type": "error", "error": {"type": "api_error", "message": message}} + return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" + if path == "/v1/responses": + # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. + body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, + "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} + return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" + body = {"error": {"message": message, "type": "upstream_error", "code": status}} + return b"data: " + json.dumps(body).encode() + b"\n\n" + + +HOP_BY_HOP = { + "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", + "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", +} + + +def validate_upstream(upstream, *, fixture=False): + """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" + parsed = urlsplit(upstream) + if ( + parsed.scheme not in {"https", "http"} + or not parsed.hostname + or parsed.username + or parsed.password + or parsed.query + or parsed.fragment + ): + raise ValueError("Model upstream must be a plain http(s) base URL without credentials") + try: + loopback = ipaddress.ip_address(parsed.hostname).is_loopback + except ValueError: + loopback = parsed.hostname.lower() == "localhost" + if loopback and not fixture: + raise ValueError("A loopback model upstream is restricted to explicit local fixtures") + if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": + raise ValueError("Google requires TLS") + return parsed + + +def routing_headers(value): + """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" + headers = json.loads(value or "{}") + if (not isinstance(headers, dict) + or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) + or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): + raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") + return {k.lower(): v for k, v in headers.items()} + + +def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): + if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: + raise ValueError("A JSON request with a model name is required") + if model and value["model"] != model: + raise ValueError("The gateway serves only the evaluated model") + if SERVER_SIDE_FIELDS & set(value): + raise ValueError("Provider-side search/fetch/execution fields are not allowed") + if remote_reference({k: v for k, v in value.items() if k != "tools"}): + raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") + tools = value.get("tools") or [] + if not isinstance(tools, list) or any( + not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): + raise ValueError("Only client-executed function tools are allowed") + if urlsplit(upstream).hostname == GOOGLE_HOST: + return {key: item for key, item in value.items() if key != "store"} + return value + + +def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, + model=None): + parsed = validate_upstream(upstream, fixture=fixture) + extra_headers = routing_headers(json.dumps(extra_headers or {})) + base_path = parsed.path.rstrip("/") + lock = threading.Lock() + + class Handler(BaseHTTPRequestHandler): + def log_message(self, *_args): + pass + + def do_GET(self): + if self.path != "/health": + self.send_error(404) + return + self.send_response(200) + self.send_header("Content-Type", "application/json") + self.end_headers() + self.wfile.write(b'{"ok":true}') + + def do_POST(self): + # Route on the path; a query string (the Anthropic SDK's beta client sends /v1/messages?beta=true) + # is forwarded to the provider unchanged. + request_url = urlsplit(self.path) + route = request_url.path + target = ROUTES.get(route) + if target is None: + self.send_error(404) + return + forwarded_path = base_path + target + ("?" + request_url.query if request_url.query else "") + try: + if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): + raise ValueError("A complete JSON Content-Length body is required") + length = int(self.headers["Content-Length"]) + if not 0 < length <= MAX_BODY: + raise ValueError("Request body size out of bounds") + incoming = json.loads(self.rfile.read(length)) + outgoing = compatible_body(incoming, upstream, path=route, model=model) + payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() + except (ValueError, TypeError): + self.send_error(400, "Unsupported model gateway request") + return + if audit is not None: + if not fixture: + raise RuntimeError("Provider body capture is forbidden outside fixtures") + with lock: + audit(incoming, outgoing) + connection = ( + http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection + )(parsed.hostname, parsed.port, timeout=None) + headers = {key: value for key, value in self.headers.items() + if key.lower() not in HOP_BY_HOP and key.lower() not in OPERATOR_ONLY_HEADERS} + sent = {key.lower() for key in headers} + headers.update({key: value for key, value in extra_headers.items() if key not in sent}) + headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", + # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a + # slow stream is answered with the gateway's own headers, so a provider + # Content-Encoding (Google gzips streams on request) could not be passed on. + "Accept-Encoding": "identity"}) + # The upstream call runs in a worker so a slow streamed answer can be kept alive (see + # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. + result = {} + done = threading.Event() + + abort_lock = threading.Lock() + provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has + # no Content-Length (streams), after which connection.sock is None + + def call(): + try: + connection.connect() + with abort_lock: + provider_sock["sock"] = connection.sock + if provider_sock.get("aborted"): + raise ConnectionAbortedError("caller disconnected before the request was sent") + connection.request("POST", forwarded_path, payload, headers) + result["response"] = connection.getresponse() + except (OSError, http.client.HTTPException) as error: + result["error"] = error + finally: + done.set() + + def abort_upstream(): + # Shut the provider socket down (not just close it) so a read blocked in another thread returns + # and the provider sees the disconnect and can stop a generation nobody will read. + with abort_lock: + provider_sock["aborted"] = True + sock = provider_sock.get("sock") or connection.sock + if sock is not None: + try: + sock.shutdown(socket.SHUT_RDWR) + except OSError: + pass + connection.close() + + relay_done = threading.Event() + + def watch_caller(): + # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next + # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. + while not relay_done.wait(CLIENT_POLL): + if client_gone(self.connection): + abort_upstream() + return + + def wait_upstream(seconds=None): + """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" + deadline = None if seconds is None else time.monotonic() + seconds + while not done.is_set(): + step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) + if step <= 0: + return True + if done.wait(step): + break + if client_gone(self.connection): + raise ConnectionAbortedError("caller disconnected") + return True + + threading.Thread(target=call, daemon=True).start() + try: + streamed = incoming.get("stream") is True + wait_upstream(STREAM_COMMIT_AFTER if streamed else None) + if done.is_set() or not streamed: + wait_upstream() + if "error" in result: + # No retry: an ambiguous upstream attempt stays ambiguous. + self.close_connection = True + return + response = result["response"] + self.send_response(response.status, response.reason) + for key, value in response.getheaders(): + if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: + self.send_header(key, value) + self.send_header("Connection", "close") + self.end_headers() + else: + # Slow streamed answer: commit an event stream now and send SSE comments (ignored + # by every SSE client) until the provider answers. + self.send_response(200) + self.send_header("Content-Type", "text/event-stream") + self.send_header("Cache-Control", "no-cache") + self.send_header("Connection", "close") + self.end_headers() + self.wfile.flush() + while not done.is_set(): + wait_upstream(STREAM_KEEPALIVE) + if not done.is_set(): + self.wfile.write(b": keepalive\n\n") + self.wfile.flush() + response = result.get("response") + encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" + if response is not None and response.status == 200 and encoding != "identity": + # Our headers are already sent without Content-Encoding: never relay bytes the caller + # cannot decode; fail visibly instead. + self.wfile.write(stream_error(route, f"Upstream sent Content-Encoding {encoding!r} " + "despite Accept-Encoding: identity", 502)) + self.wfile.flush() + self.close_connection = True + return + if response is None or response.status != 200: + status = getattr(response, "status", None) + detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" + message = (f"Upstream HTTP {status}: {detail}" if response is not None + else f"Upstream connection error: {type(result.get('error')).__name__}") + self.wfile.write(stream_error(route, message, status)) + self.wfile.flush() + self.close_connection = True + return + threading.Thread(target=watch_caller, daemon=True).start() + while data := response.read1(65536): + self.wfile.write(data) + self.wfile.flush() + self.close_connection = True + except (OSError, http.client.HTTPException, ValueError): + # ValueError: the watchdog closed the upstream response under a blocked read. + self.close_connection = True + finally: + relay_done.set() + abort_upstream() + + return ThreadingHTTPServer((host, port), Handler) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--host", default="0.0.0.0") + parser.add_argument("--port", type=int, default=8003) + parser.add_argument("--fixture-upstream", help="Explicit local mock only") + args = parser.parse_args() + upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE + owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), + extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), + model=os.environ.get("CI_MODEL_NAME") or None) + print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), + "upstream_host": urlsplit(upstream).hostname}), flush=True) + owned.serve_forever() + + +if __name__ == "__main__": + main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/runtime.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/runtime.json index 5c05ecbbe8bf062dc777b55f6cb09d28c0ea6386..d999eb266c151fd59ccf39757c70d3be299bbff5 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/runtime.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "archive_sha256": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -9,31 +9,32 @@ "adapter/collab_harbor/command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "adapter/collab_harbor/compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "adapter/collab_harbor/continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "adapter/collab_harbor/dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "adapter/collab_harbor/export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "adapter/collab_harbor/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/collab_harbor/flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "adapter/collab_harbor/flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "adapter/collab_harbor/generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "adapter/collab_harbor/grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "adapter/collab_harbor/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "adapter/collab_harbor/model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "adapter/collab_harbor/pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "adapter/collab_harbor/pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "adapter/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "adapter/collab_harbor/pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "adapter/collab_harbor/pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "adapter/collab_harbor/private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "adapter/collab_harbor/private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "adapter/collab_harbor/provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "adapter/collab_harbor/pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "adapter/collab_harbor/reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "adapter/collab_harbor/replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "adapter/collab_harbor/run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", - "adapter/collab_harbor/runtime-files.json": "675382b88a6dd8dd23b8825a7017af26d6d0c900c4f6dc6f0ecbd88aea9d0354", + "adapter/collab_harbor/run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", + "adapter/collab_harbor/runtime-files.json": "2c91e60ab99be36ae8b28cd1aaa23a2b3b5be4193287f787507f8b3fa7a40726", "adapter/collab_harbor/runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "adapter/collab_harbor/scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "adapter/collab_harbor/service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "adapter/collab_harbor/scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "adapter/collab_harbor/service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "adapter/collab_harbor/sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "adapter/collab_harbor/stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "adapter/collab_harbor/takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/collab_harbor/takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "adapter/collab_harbor/vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "adapter/collab_harbor/workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8", "upstream/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -99,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1472807, + "uncompressed_bytes": 1475357, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/runtime.tar.gz b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/runtime.tar.gz index 57436434d48ab3d4c29df74e3d542be7d0b25451..f74033c23a84d62b55e8967d2a1521b6d9e52653 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/runtime.tar.gz +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1 -size 392924 +oid sha256:d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6 +size 393898 diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/task.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/task.json index 51c43148235213bc78a73a4d2919de28cdc88203..a83f61bd5df292b3fce05bc81a7b820df4397ce6 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/task.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/environment/team/task.json @@ -56,34 +56,35 @@ "command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", + "run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", "runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "0b48c4938c9a4e7cdb23a3146908442f6f0c6c986359b88cc6d5a04b15f5eceb" + "sha256": "fcb79c83102403397f7c05d3d991ba64ea673de9d2b6590ead92de24f2159515" }, "verifier_adapter": { "schema_version": 1, @@ -95,34 +96,35 @@ "command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", + "run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", "runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8" }, - "sha256": "0b48c4938c9a4e7cdb23a3146908442f6f0c6c986359b88cc6d5a04b15f5eceb" + "sha256": "fcb79c83102403397f7c05d3d991ba64ea673de9d2b6590ead92de24f2159515" }, "team_upstream": { "schema_version": 1, @@ -248,26 +250,26 @@ "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1" + "runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6" }, - "sha256": "1fd45d5914f5f155eafafb0b47004e37e96fcc4de63db16762bebb89d8bb2014" + "sha256": "a03d87d987a703bbfbe6ca5b05ce2f489745dd956de2df32fc9b9effd9dba42b" }, "verifier_runtime_distribution": { "schema_version": 1, "files": { "runtime-unpack.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", - "runtime.json": "6c57f33c331fdcc7deaff4b283c62a58e05310a07014c4da4fdcdd3be965d6e9", - "runtime.tar.gz": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1" + "runtime.json": "21bee6fa623e0539f9c2faf92869cd2b4b40c772a9002b2f4871464cddf86ebf", + "runtime.tar.gz": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6" }, - "sha256": "1fd45d5914f5f155eafafb0b47004e37e96fcc4de63db16762bebb89d8bb2014" + "sha256": "a03d87d987a703bbfbe6ca5b05ce2f489745dd956de2df32fc9b9effd9dba42b" }, "runtime_distribution": { "schema_version": 1, "files": { - "runtime-distribution.json": "86a364434305d761e9a9249b6cfcf0ab649d3bd6eb084c112068c65ac1a89817" + "runtime-distribution.json": "534865bee3118019fc3284e1de6841fff5d85b8f1f65b7038ef4539baf77993d" }, - "sha256": "f4a7684277c4d2ccf2ed76b054a17f2ffc301c220078ab7c2fcc3aedadd0f6d7" + "sha256": "6b39152523a378b895a53f8e0cf9e93af51b9e6a9b33532f19a062595a30fc4e" }, "environment_policy": { "schema_version": 1, @@ -313,10 +315,10 @@ "sha256": "33b10cc4a7d760c70a490b186618d63dd730389503da1396eec47afc8b436d60" } }, - "sha256": "716a2647d4085f9cfa2dcacb9f311117b42c8c28e0568586ab80b780d98c320a" + "sha256": "94abcaafde47cf03191246ffa0e7b8e08f453ba0fd8cad1091d6f37488216a67" }, "runtime_distribution": { "format": "ci-private-runtime-tar-gzip-v1", - "archive_sha256": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1" + "archive_sha256": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6" } } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/task.toml b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/task.toml index 8662dbb7f09fcf6c8b30ce1f5b9716d629b7d8e9..271cec22e44018ad269bf2328756495267e3a03a 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/task.toml +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/task.toml @@ -36,5 +36,5 @@ timeout_sec = 150 [[verifier.collect]] service = "team" -command = "python -m collab_harbor.export" +command = "python -m collab_harbor.export_evidence" timeout_sec = 86400 diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/runtime.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/runtime.json index 5c05ecbbe8bf062dc777b55f6cb09d28c0ea6386..d999eb266c151fd59ccf39757c70d3be299bbff5 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/runtime.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/runtime.json @@ -1,5 +1,5 @@ { - "archive_sha256": "33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1", + "archive_sha256": "d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6", "files": { "adapter/collab_harbor/LICENSE.adapter": "c71d239df91726fc519c6eb72d318ec65820627232b2f796219e87dcf35d0ab4", "adapter/collab_harbor/__init__.py": "3b4ee476f940b1d71ce30ea8024133a316db9def990e4050c258c994a34b968e", @@ -9,31 +9,32 @@ "adapter/collab_harbor/command_execution.py": "3f094fb3031769e95d01070426b37aaf2077fde116c7079e952126b8ec44a69f", "adapter/collab_harbor/compact_runtime.py": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0", "adapter/collab_harbor/continuation.py": "cfcafd1360d473a77308dc0961e4a8afeb2d081c3a87e916c13deec43ad7553a", - "adapter/collab_harbor/dimension_generate.py": "12623dea26c05f797a6bff71637a448054f9eceec15f13a85ba73ea3c739e6d1", - "adapter/collab_harbor/export.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", + "adapter/collab_harbor/dimension_generate.py": "b8078bf85193da8c0806e2733a39ce4ef8882be571d0c61d300dff8b1daac5b1", + "adapter/collab_harbor/export_evidence.py": "a8c9feb1a8e66d473fd871edc83753a779d1951f7dd3525a2bce9550f4739726", "adapter/collab_harbor/file_integrity.py": "2d3d87971c12dce95ecc1747cd365dccdda37331d19296a0e6d011b0f51cf4e0", - "adapter/collab_harbor/generate.py": "08f78596dd666f5b34244519d7976853f30a8cc4639a1af81f49d40651c1eba0", - "adapter/collab_harbor/google_compat.py": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b", - "adapter/collab_harbor/google_compat_task.py": "8b48e61b1eafd878e41b57f63c04735381b375fdd9e532a15f5e9e395ac6884c", - "adapter/collab_harbor/grade.py": "e9852a96db808d41c0d1ab16ac98d54c5c5e17cd75c94ba8c53c81ba76eaf9f2", - "adapter/collab_harbor/live_reader_gate.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/collab_harbor/flock_config.py": "88c4a04434d7f5dd874cf005c99a938e98cee1d00901cc26aa186cdb5586525b", + "adapter/collab_harbor/flock_results.py": "ff1b18275c9c98baa2c40ae554c5bc61a0e902061d14066e7dccd82f3f8f0de5", + "adapter/collab_harbor/generate.py": "0f5fc0caebdb9273c8332327d98861149bf2bfb24faccb5738d315601eab39b9", + "adapter/collab_harbor/grade.py": "6f335e5bea88732ffb99642f9a7f0e070e3ae3ab5cf02f2fad9ef1460e8a1fe3", + "adapter/collab_harbor/model_gateway.py": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78", + "adapter/collab_harbor/model_gateway_setup.py": "a1da429a2a48addf1658a51c98d0ce483ca0e8fc2ef7a5377fc662527d407364", "adapter/collab_harbor/pi-bash-timeout.js": "aeba75d3703c9f1e5be548a7153c3a472cc1210931aa98ddc914310901ba689a", "adapter/collab_harbor/pi-capture.js": "0ed9179bd9d11917f923a186e047812b82ec2d35efa085031fbac64551364be0", "adapter/collab_harbor/pi-google.js": "76bba2d5107bc25062cd5f17a8cb8de8630a35ab3cec6ec395068a3fb5b29159", "adapter/collab_harbor/pi_bash_timeout.py": "a64dff662959e47d25a02d621626e5f28d3f4831b0f7afb84a3086bdba0a8bca", "adapter/collab_harbor/pi_capture.py": "4aee3f8f0843b1770132daea1c2c084f41fc1022e185beb3140b925324b0dd58", - "adapter/collab_harbor/private_readout.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", + "adapter/collab_harbor/private_final_answers.py": "29238d7ba70efc6720feb6ac91f7be68310a50da35cb5d37b8aeecbdc9997079", "adapter/collab_harbor/provenance.py": "784cb670ed8abb950df81a12c71f68c2f88299956b27b0ffd094befa133637ca", "adapter/collab_harbor/pytest_child.py": "7d2cb2abddd752cce2d938f2d8ab1a7bfe0761fa9f9c5490053bc0252ab04f61", - "adapter/collab_harbor/reader_scoring.py": "0281f38b52a49a5a3e1484e3f3590cec736ad46fbec79ba446823be0e0305a34", "adapter/collab_harbor/replay.py": "537f256b380c46165f486a1f3749a7d9749391c0afe8326e6f3a8b441f45a05c", - "adapter/collab_harbor/run_benchmark.py": "f7b0f83f7c6ce4b92f8a33195eafa6241c21ff4116523ca0320254227d1659ae", - "adapter/collab_harbor/runtime-files.json": "675382b88a6dd8dd23b8825a7017af26d6d0c900c4f6dc6f0ecbd88aea9d0354", + "adapter/collab_harbor/run_benchmark.py": "53724aee74171151688518c57850f5e8bcb0caa04a7f36d331177ea18cd35f15", + "adapter/collab_harbor/runtime-files.json": "2c91e60ab99be36ae8b28cd1aaa23a2b3b5be4193287f787507f8b3fa7a40726", "adapter/collab_harbor/runtime-requirements.lock": "dee41783bcc20ef627c1f64df7e1320de9765e67df948079697d206962628fa2", - "adapter/collab_harbor/scoring.py": "546eb7a81656b6c4b8f6271e1a9260d13a348233daeb4006c3ee918876fffc3d", - "adapter/collab_harbor/service.py": "666b466bc6947f4262113b7042a21ac4ba452f4c01baeeb1a0189a55b698fdad", + "adapter/collab_harbor/scoring.py": "4ad24fa25313a95f53987c75c4b8aa06a6d88a1dddcdbe02807954bdb04ac630", + "adapter/collab_harbor/service.py": "872a4505aefb71657a2279e33e5facbe8ec85f559a34168c35e269e6d8c69fa3", "adapter/collab_harbor/sources.py": "eb24a9c8271ce298bcd583ecc2bdf54c96df94fea7450d537c208754a5082315", - "adapter/collab_harbor/stock_execution.py": "8e691e15d4e974be01c583f81618d2775fcecec0570985744c26e04a2789953e", + "adapter/collab_harbor/takeover_grader.py": "7c7daf586ed0735d18a724886bd450e42cf3f619afcd88dc69189ba9298145c7", + "adapter/collab_harbor/takeover_verdicts.py": "769992e619cb6640e8bb5231f82da178ff016501b6105687bb0397ad80554a17", "adapter/collab_harbor/vendor.py": "ae5ac88b824bb4775c0ce278f4003f3a036def9d5049caf27290ff0d52b71e51", "adapter/collab_harbor/workspace_evidence.py": "b1abf1b142440c9e213668c8feb690b89446777de8de12d51fb7e9479e3ee8d8", "upstream/LICENSE": "bfa9f372762062762c414e4b5dbdf896067dd39c4a2ec5f7c3c93469dbda7852", @@ -99,6 +100,6 @@ }, "format": "ci-private-runtime-tar-gzip-v1", "schema_version": 1, - "uncompressed_bytes": 1472807, + "uncompressed_bytes": 1475357, "unpacker_sha256": "55afb6f2af4a81089f57643fc8eb46ba355925a73abaedc91c7670010094ada0" } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/runtime.tar.gz b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/runtime.tar.gz index 57436434d48ab3d4c29df74e3d542be7d0b25451..f74033c23a84d62b55e8967d2a1521b6d9e52653 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/runtime.tar.gz +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s1/tests/runtime.tar.gz @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:33ff7f50f667cedb5df9e4fce5b04b66ef0decdafc61430d0392819b1a3dd2b1 -size 392924 +oid sha256:d4490ed247e1819e4539566516e5961370f493cc5586f90e639462015b4755c6 +size 393898 diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/Dockerfile b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/Dockerfile index a3b70c6bc89afece994c29d00a170866b8613806..94aa12bd481e74988451e2982dd1af085dea3e96 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/Dockerfile +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/Dockerfile @@ -1,5 +1,5 @@ FROM python:3.13-slim-bookworm@sha256:281d39ff02e3b389401586134ff9e6572954687822a58055ec07a60ded4e0b7f -COPY google_compat.py /app/google_compat.py -RUN chmod 644 /app/google_compat.py +COPY model_gateway.py /app/model_gateway.py +RUN chmod 644 /app/model_gateway.py USER 65534:65534 -ENTRYPOINT ["python", "-B", "/app/google_compat.py"] +ENTRYPOINT ["python", "-B", "/app/model_gateway.py"] diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/compatibility.json b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/compatibility.json index b4dd079fb5f4c07a63a11dc4e3cda203a0adad9a..8d3b92c6ad226a57604a74d9fb00a53f605c8b2f 100644 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/compatibility.json +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/compatibility.json @@ -17,5 +17,5 @@ "model-compat" ], "agent_main_explicit_networks": false, - "source_sha256": "de93a1b41a5e9488620092ced37f75976068a7921a8e01fab79190d718fed28b" + "source_sha256": "7b5a23c91f1d0caff5e015e670dc3be50b686c210b079f2e175d61cef8640a78" } diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/model_gateway.py b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/model_gateway.py new file mode 100644 index 0000000000000000000000000000000000000000..96dc58b5e6e763197a75c1a95aaec45159dbc864 --- /dev/null +++ b/tasks/ci-keeping-the-team-on-track-h-l-db-restore-source-test-s2/environment/model-compat/model_gateway.py @@ -0,0 +1,383 @@ +"""Task-local model gateway: the evaluated agent's only route to its model provider. + +The agent container has no internet during its run (Harbor allowlist: team and +model-compat). Pi sends every model request here, and so does the team +service's private final-answer readout. The gateway forwards each request, +unchanged except as noted, to one configured upstream: + +* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the + provider base URL including its version prefix, e.g. + ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an + inference endpoint's ``https://.../v1``. +* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to + ``/chat/completions``, ``/responses`` and ``/messages``. +* The only body change: for Google's endpoint, drop the optional top-level + ``store`` field (also in Pi's internal compaction calls), which Google rejects. +* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so + the agent cannot use the gateway to reach a different model. +* Only client-executed function tools pass. Provider-side tools (web search, web + fetch, MCP, code containers) are rejected: they would let the agent reach the + internet through the provider despite the network allowlist. +* Remote content references are rejected too (``image_url``/``file_url``/... pointing + anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider + would fetch them on the agent's behalf. URLs inside plain text are not fetched. +* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did + not send; only ``anthropic-workspace-id``, ``openai-organization``, + ``openai-project`` and ``x-hf-bill-to`` are accepted (an unscoped Anthropic key + needs the first). ``x-hf-bill-to`` (Hugging Face org billing) is operator-only: + a caller's own copy is removed and only the configured value is sent. + +* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event + stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): + Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway + always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). + +No credentials are owned or stored (the caller's auth headers pass through), no +content is logged, and nothing is retried: an ambiguous upstream attempt stays +ambiguous. +""" + +from __future__ import annotations + +import argparse +import http.client +import ipaddress +import json +import os +import select +import socket +import threading +import time +from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer +from urllib.parse import urlsplit + +GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" +GOOGLE_HOST = "generativelanguage.googleapis.com" +ROUTES = { + "/v1/chat/completions": "/chat/completions", + "/v1/responses": "/responses", + "/v1/messages": "/messages", +} +ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project", "x-hf-bill-to"} +# Set only by the operator (CI_MODEL_HEADERS): a caller's own copy is always removed, so the agent cannot choose +# which organization is billed. +OPERATOR_ONLY_HEADERS = {"x-hf-bill-to"} +MAX_BODY = 32 * 1024 * 1024 +# Request fields that make the provider fetch or run things server-side. +SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} +CLIENT_TOOL_TYPES = { + "/v1/chat/completions": {"function"}, + "/v1/responses": {"function", "custom"}, + "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") +} +REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} + + +def remote_reference(value): + """True if the request asks the provider to fetch content from a URL.""" + if isinstance(value, dict): + if value.get("type") == "url" and isinstance(value.get("url"), str): + return True # Anthropic image/document source + for key, item in value.items(): + if key in REMOTE_KEYS: + url = item.get("url") if isinstance(item, dict) else item + if isinstance(url, str) and not url.startswith("data:"): + return True + if remote_reference(item): + return True + elif isinstance(value, list): + return any(remote_reference(item) for item in value) + return False + + +# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays +# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER +# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds +# until the provider answers; the provider's stream is then relayed unchanged. A late provider +# error becomes the stream error event of that API. Fast answers (and all errors that arrive +# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. +STREAM_COMMIT_AFTER = 3.0 +STREAM_KEEPALIVE = 5.0 +CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected + + +def client_gone(sock): + """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" + try: + readable, _, _ = select.select([sock], [], [], 0) + return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" + except OSError: + return True + + +def stream_error(path, message, status=None): + """One SSE error event in the format the API's official SDK raises on.""" + if path == "/v1/messages": + body = {"type": "error", "error": {"type": "api_error", "message": message}} + return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" + if path == "/v1/responses": + # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. + body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, + "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} + return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" + body = {"error": {"message": message, "type": "upstream_error", "code": status}} + return b"data: " + json.dumps(body).encode() + b"\n\n" + + +HOP_BY_HOP = { + "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", + "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", +} + + +def validate_upstream(upstream, *, fixture=False): + """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" + parsed = urlsplit(upstream) + if ( + parsed.scheme not in {"https", "http"} + or not parsed.hostname + or parsed.username + or parsed.password + or parsed.query + or parsed.fragment + ): + raise ValueError("Model upstream must be a plain http(s) base URL without credentials") + try: + loopback = ipaddress.ip_address(parsed.hostname).is_loopback + except ValueError: + loopback = parsed.hostname.lower() == "localhost" + if loopback and not fixture: + raise ValueError("A loopback model upstream is restricted to explicit local fixtures") + if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": + raise ValueError("Google requires TLS") + return parsed + + +def routing_headers(value): + """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" + headers = json.loads(value or "{}") + if (not isinstance(headers, dict) + or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) + or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): + raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") + return {k.lower(): v for k, v in headers.items()} + + +def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): + if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: + raise ValueError("A JSON request with a model name is required") + if model and value["model"] != model: + raise ValueError("The gateway serves only the evaluated model") + if SERVER_SIDE_FIELDS & set(value): + raise ValueError("Provider-side search/fetch/execution fields are not allowed") + if remote_reference({k: v for k, v in value.items() if k != "tools"}): + raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") + tools = value.get("tools") or [] + if not isinstance(tools, list) or any( + not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): + raise ValueError("Only client-executed function tools are allowed") + if urlsplit(upstream).hostname == GOOGLE_HOST: + return {key: item for key, item in value.items() if key != "store"} + return value + + +def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, + model=None): + parsed = validate_upstream(upstream, fixture=fixture) + extra_headers = routing_headers(json.dumps(extra_headers or {})) + base_path = parsed.path.rstrip("/") + lock = threading.Lock() + + class Handler(BaseHTTPRequestHandler): + def log_message(self, *_args): + pass + + def do_GET(self): + if self.path != "/health": + self.send_error(404) + return + self.send_response(200) + self.send_header("Content-Type", "application/json") + self.end_headers() + self.wfile.write(b'{"ok":true}') + + def do_POST(self): + # Route on the path; a query string (the Anthropic SDK's beta client sends /v1/messages?beta=true) + # is forwarded to the provider unchanged. + request_url = urlsplit(self.path) + route = request_url.path + target = ROUTES.get(route) + if target is None: + self.send_error(404) + return + forwarded_path = base_path + target + ("?" + request_url.query if request_url.query else "") + try: + if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): + raise ValueError("A complete JSON Content-Length body is required") + length = int(self.headers["Content-Length"]) + if not 0 < length <= MAX_BODY: + raise ValueError("Request body size out of bounds") + incoming = json.loads(self.rfile.read(length)) + outgoing = compatible_body(incoming, upstream, path=route, model=model) + payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() + except (ValueError, TypeError): + self.send_error(400, "Unsupported model gateway request") + return + if audit is not None: + if not fixture: + raise RuntimeError("Provider body capture is forbidden outside fixtures") + with lock: + audit(incoming, outgoing) + connection = ( + http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection + )(parsed.hostname, parsed.port, timeout=None) + headers = {key: value for key, value in self.headers.items() + if key.lower() not in HOP_BY_HOP and key.lower() not in OPERATOR_ONLY_HEADERS} + sent = {key.lower() for key in headers} + headers.update({key: value for key, value in extra_headers.items() if key not in sent}) + headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", + # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a + # slow stream is answered with the gateway's own headers, so a provider + # Content-Encoding (Google gzips streams on request) could not be passed on. + "Accept-Encoding": "identity"}) + # The upstream call runs in a worker so a slow streamed answer can be kept alive (see + # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. + result = {} + done = threading.Event() + + abort_lock = threading.Lock() + provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has + # no Content-Length (streams), after which connection.sock is None + + def call(): + try: + connection.connect() + with abort_lock: + provider_sock["sock"] = connection.sock + if provider_sock.get("aborted"): + raise ConnectionAbortedError("caller disconnected before the request was sent") + connection.request("POST", forwarded_path, payload, headers) + result["response"] = connection.getresponse() + except (OSError, http.client.HTTPException) as error: + result["error"] = error + finally: + done.set() + + def abort_upstream(): + # Shut the provider socket down (not just close it) so a read blocked in another thread returns + # and the provider sees the disconnect and can stop a generation nobody will read. + with abort_lock: + provider_sock["aborted"] = True + sock = provider_sock.get("sock") or connection.sock + if sock is not None: + try: + sock.shutdown(socket.SHUT_RDWR) + except OSError: + pass + connection.close() + + relay_done = threading.Event() + + def watch_caller(): + # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next + # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. + while not relay_done.wait(CLIENT_POLL): + if client_gone(self.connection): + abort_upstream() + return + + def wait_upstream(seconds=None): + """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" + deadline = None if seconds is None else time.monotonic() + seconds + while not done.is_set(): + step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) + if step <= 0: + return True + if done.wait(step): + break + if client_gone(self.connection): + raise ConnectionAbortedError("caller disconnected") + return True + + threading.Thread(target=call, daemon=True).start() + try: + streamed = incoming.get("stream") is True + wait_upstream(STREAM_COMMIT_AFTER if streamed else None) + if done.is_set() or not streamed: + wait_upstream() + if "error" in result: + # No retry: an ambiguous upstream attempt stays ambiguous. + self.close_connection = True + return + response = result["response"] + self.send_response(response.status, response.reason) + for key, value in response.getheaders(): + if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: + self.send_header(key, value) + self.send_header("Connection", "close") + self.end_headers() + else: + # Slow streamed answer: commit an event stream now and send SSE comments (ignored + # by every SSE client) until the provider answers. + self.send_response(200) + self.send_header("Content-Type", "text/event-stream") + self.send_header("Cache-Control", "no-cache") + self.send_header("Connection", "close") + self.end_headers() + self.wfile.flush() + while not done.is_set(): + wait_upstream(STREAM_KEEPALIVE) + if not done.is_set(): + self.wfile.write(b": keepalive\n\n") + self.wfile.flush() + response = result.get("response") + encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" + if response is not None and response.status == 200 and encoding != "identity": + # Our headers are already sent without Content-Encoding: never relay bytes the caller + # cannot decode; fail visibly instead. + self.wfile.write(stream_error(route, f"Upstream sent Content-Encoding {encoding!r} " + "despite Accept-Encoding: identity", 502)) + self.wfile.flush() + self.close_connection = True + return + if response is None or response.status != 200: + status = getattr(response, "status", None) + detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" + message = (f"Upstream HTTP {status}: {detail}" if response is not None + else f"Upstream connection error: {type(result.get('error')).__name__}") + self.wfile.write(stream_error(route, message, status)) + self.wfile.flush() + self.close_connection = True + return + threading.Thread(target=watch_caller, daemon=True).start() + while data := response.read1(65536): + self.wfile.write(data) + self.wfile.flush() + self.close_connection = True + except (OSError, http.client.HTTPException, ValueError): + # ValueError: the watchdog closed the upstream response under a blocked read. + self.close_connection = True + finally: + relay_done.set() + abort_upstream() + + return ThreadingHTTPServer((host, port), Handler) + + +def main(): + parser = argparse.ArgumentParser(description=__doc__) + parser.add_argument("--host", default="0.0.0.0") + parser.add_argument("--port", type=int, default=8003) + parser.add_argument("--fixture-upstream", help="Explicit local mock only") + args = parser.parse_args() + upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE + owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), + extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), + model=os.environ.get("CI_MODEL_NAME") or None) + print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), + "upstream_host": urlsplit(upstream).hostname}), flush=True) + owned.serve_forever() + + +if __name__ == "__main__": + main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-meeting-day-evening-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-routing-storm-node-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-tower-source-genomes-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-l-wedding-raspberry-trace-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-failover-scorecard-first-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-fuel-vs-gear-hold-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-hotfix-scope-creep-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-n-or-depth-vs-tube-fixation-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-9-neonatal-rcdp-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-lcbhard-23-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-on-track-fermions-well-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-track-high-energy-particle-physics-kntno-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-r-track-physics-general-bu5rh-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-h-x-puzzlehunt-tiles-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-cabin-seizure-distractors-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-craniotomy-prep-five-minutes-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-peds-asthma-to-shock-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-n-trauma-holding-to-tension-ptx-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/model-compat/google_compat.py b/tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-keeping-the-team-on-track-r-10-ecmo-transport-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-l-photo-meeting-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-l-photo-meeting-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-l-photo-meeting-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-l-photo-meeting-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-l-retained-rock-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-l-retained-rock-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-l-retained-rock-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-l-retained-rock-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-n-lead-investor-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-n-lead-investor-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-n-lead-investor-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-n-lead-investor-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-r-choosing-the-safe-field-station-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-r-choosing-the-safe-field-station-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-r-critical-vaccine-route-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-r-critical-vaccine-route-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-r-critical-vaccine-route-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-r-critical-vaccine-route-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-x-negotiation-site-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-x-negotiation-site-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-x-negotiation-site-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-h2-x-negotiation-site-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-l-lqts-father-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-lqts-father-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-l-lqts-father-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-l-lqts-father-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-lqts-father-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-l-lqts-father-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-l-lqts-father-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-lqts-father-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-l-lqts-father-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-l-lqts-father-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-lqts-father-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-l-lqts-father-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-l-pregabalin-sachet-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-l-pregabalin-sachet-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-l-pregabalin-sachet-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-l-pregabalin-sachet-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-l-signout-drowsy-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-l-signout-drowsy-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-signout-drowsy-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-l-signout-drowsy-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-l-signout-drowsy-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-signout-drowsy-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-l-signout-drowsy-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-l-signout-drowsy-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-signout-drowsy-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-l-signout-drowsy-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-l-storm-advisory-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-storm-advisory-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-l-storm-advisory-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-l-storm-advisory-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-l-storm-advisory-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-l-storm-advisory-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-n-jersey-teams-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-n-jersey-teams-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-n-jersey-teams-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-n-jersey-teams-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-jersey-teams-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-n-jersey-teams-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-n-palindrome-bound-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-n-palindrome-bound-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-palindrome-bound-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-n-palindrome-bound-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-n-palindrome-bound-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-palindrome-bound-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-n-palindrome-bound-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-n-palindrome-bound-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-palindrome-bound-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-n-palindrome-bound-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-n-tamponade-alternans-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-n-tamponade-alternans-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-n-tamponade-alternans-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-n-tamponade-alternans-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-n-triangle-area-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-triangle-area-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-n-triangle-area-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-n-triangle-area-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-triangle-area-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-n-triangle-area-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-n-triangle-area-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-triangle-area-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-n-triangle-area-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-n-triangle-area-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-n-triangle-area-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-n-triangle-area-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-beaded-lizards-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-beaded-lizards-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-beaded-lizards-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-beaded-lizards-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-beaded-lizards-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-beaded-lizards-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-beaded-lizards-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-beaded-lizards-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-beaded-lizards-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-beaded-lizards-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-emergency-aircraft-landing-site-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-emergency-aircraft-landing-site-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-emergency-evacuation-center-choice-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-emergency-evacuation-center-choice-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-emperor-regiment-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-emperor-regiment-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-emperor-regiment-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-emperor-regiment-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-emperor-regiment-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-emperor-regiment-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-emperor-regiment-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-emperor-regiment-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-emperor-regiment-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-emperor-regiment-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-field-trip-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-field-trip-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-field-trip-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-field-trip-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-field-trip-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-field-trip-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-field-trip-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-field-trip-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-field-trip-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-r-field-trip-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-r-field-trip-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-r-field-trip-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-x-sensor-placement-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-x-sensor-placement-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-x-sensor-placement-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-x-sensor-placement-test-s0/environment/model-compat/google_compat.py b/tasks/ci-sharing-x-sensor-placement-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-x-sensor-placement-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-x-sensor-placement-test-s1/environment/model-compat/google_compat.py b/tasks/ci-sharing-x-sensor-placement-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-x-sensor-placement-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-sharing-x-sensor-placement-test-s2/environment/model-compat/google_compat.py b/tasks/ci-sharing-x-sensor-placement-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-sharing-x-sensor-placement-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-loadsheet-late-transfer--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-recall-hold-lots--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-recall-hold-lots--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-recall-hold-lots--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-review-extraction-swap--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-review-extraction-swap--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-review-extraction-swap--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-theatre-list-latex--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-theatre-list-latex--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-b-theatre-list-latex--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-kb-promo-rpn-operands--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-kb-signup-date-ticket--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-kb-signup-date-ticket--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-kb-signup-date-ticket--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ks-export-slug-names--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ks-export-slug-names--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ks-export-slug-names--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ks-restore-tar-filter--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ks-restore-tar-filter--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ks-restore-tar-filter--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ks-urllib3-cookie-patch--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ku-order-history-index--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ku-order-history-index--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ku-order-history-index--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ku-order-history-index--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ku-order-history-index--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ku-payment-alert-rules--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ku-payment-alert-rules--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ku-payment-alert-rules--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-ku-season-pass-dob-privacy--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-mri-cancellation-slot--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-outage-switchboard--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-outage-switchboard--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-outage-switchboard--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-price-rise-forward-order--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-price-rise-forward-order--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-price-rise-forward-order--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-refund-window--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-refund-window--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-refund-window--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-refund-window--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-s-refund-window--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-foodbank-referral--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-foodbank-referral--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-foodbank-referral--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-lab-freezer-alarm--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-rail-passenger-assist--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-rail-passenger-assist--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-rail-passenger-assist--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-release-restore-test--r5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-release-restore-test--r5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-release-restore-test--r5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-release-restore-test--r5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-initiative-u-release-restore-test--r5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-h-l-audit-sample-truncation--q14rec1-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-h-n-oos-retest-average--q14rec2-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-h-n-rigging-signoff--q14rec3-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-l-fall-omitted-crf--q14rec4-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-l-pi-exam-signature--q14s12-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-l-pi-exam-signature--q14s12-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-l-pi-exam-signature--q14s12-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-n-ib-customer-value--dslb0k3-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-n-ib-customer-value--dslb0k3-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-n-ib-customer-value--dslb0k3-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns1k4-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-0--dsns2k4-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--deepseek11-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-1--dsns1k4-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--dsns1k6-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-28--kimi0-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-29--dsns1k4-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--deepseek8-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-3--dsns1k5-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-ib-promptB--lcbhard-8--kimilb0k4-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-15--q14s21-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-15--q14s21-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-15--q14s21-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-18--q14s23-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-18--q14s23-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-18--q14s23-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-19--q14s24-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-19--q14s24-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-19--q14s24-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-27--qwen318-baseline-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-27--qwen318-solo-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s0/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s1/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main() diff --git a/tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/model-compat/google_compat.py b/tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/model-compat/google_compat.py deleted file mode 100644 index 1b95c0a2218d5d3b49de96ee43aa228d0e648060..0000000000000000000000000000000000000000 --- a/tasks/ci-taking-over-r-lcbhard-27--qwen318-test-s2/environment/model-compat/google_compat.py +++ /dev/null @@ -1,372 +0,0 @@ -"""Task-local model gateway: the evaluated agent's only route to its model provider. - -The agent container has no internet during its run (Harbor allowlist: team and -model-compat). Pi sends every model request here, and so does the team -service's private final-answer readout. The gateway forwards each request, -unchanged except as noted, to one configured upstream: - -* ``CI_MODEL_UPSTREAM`` (default: Google's OpenAI-compatible endpoint), the - provider base URL including its version prefix, e.g. - ``https://api.openai.com/v1``, ``https://api.anthropic.com/v1`` or an - inference endpoint's ``https://.../v1``. -* Paths ``/v1/chat/completions``, ``/v1/responses`` and ``/v1/messages`` map to - ``/chat/completions``, ``/responses`` and ``/messages``. -* The only body change: for Google's endpoint, drop the optional top-level - ``store`` field (also in Pi's internal compaction calls), which Google rejects. -* ``CI_MODEL_NAME`` pins the evaluated model: any other ``model`` is rejected, so - the agent cannot use the gateway to reach a different model. -* Only client-executed function tools pass. Provider-side tools (web search, web - fetch, MCP, code containers) are rejected: they would let the agent reach the - internet through the provider despite the network allowlist. -* Remote content references are rejected too (``image_url``/``file_url``/... pointing - anywhere but an inline ``data:`` URI, Anthropic ``source: {type: url}``): the provider - would fetch them on the agent's behalf. URLs inside plain text are not fetched. -* ``CI_MODEL_HEADERS`` (JSON) may add non-secret routing headers the caller did - not send; only ``anthropic-workspace-id``, ``openai-organization`` and - ``openai-project`` are accepted (an unscoped Anthropic key needs the first). - -* A streamed request whose provider is slow (more than 3 s) is answered with a 200 event - stream and keepalive comments until the provider responds (see ``STREAM_KEEPALIVE``): - Harbor's agent egress proxy otherwise drops it after ~15 s of silence. The gateway - always asks the provider for uncompressed bytes (``Accept-Encoding: identity``). - -No credentials are owned or stored (the caller's auth headers pass through), no -content is logged, and nothing is retried: an ambiguous upstream attempt stays -ambiguous. The file keeps its historical name; it is no longer Google-specific. -""" - -from __future__ import annotations - -import argparse -import http.client -import ipaddress -import json -import os -import select -import socket -import threading -import time -from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer -from urllib.parse import urlsplit - -GOOGLE = "https://generativelanguage.googleapis.com/v1beta/openai" -GOOGLE_HOST = "generativelanguage.googleapis.com" -ROUTES = { - "/v1/chat/completions": "/chat/completions", - "/v1/responses": "/responses", - "/v1/messages": "/messages", -} -ROUTING_HEADERS = {"anthropic-workspace-id", "openai-organization", "openai-project"} -MAX_BODY = 32 * 1024 * 1024 -# Request fields that make the provider fetch or run things server-side. -SERVER_SIDE_FIELDS = {"web_search_options", "mcp_servers", "container", "search_parameters"} -CLIENT_TOOL_TYPES = { - "/v1/chat/completions": {"function"}, - "/v1/responses": {"function", "custom"}, - "/v1/messages": {None, "custom"}, # Anthropic client tools have no type (or "custom") -} -REMOTE_KEYS = {"image_url", "file_url", "audio_url", "video_url", "document_url"} - - -def remote_reference(value): - """True if the request asks the provider to fetch content from a URL.""" - if isinstance(value, dict): - if value.get("type") == "url" and isinstance(value.get("url"), str): - return True # Anthropic image/document source - for key, item in value.items(): - if key in REMOTE_KEYS: - url = item.get("url") if isinstance(item, dict) else item - if isinstance(url, str) and not url.startswith("data:"): - return True - if remote_reference(item): - return True - elif isinstance(value, list): - return any(remote_reference(item) for item in value) - return False - - -# Harbor's agent-phase egress proxy (gost, HTTP sniffing) drops a proxied connection that stays -# silent for ~15 s. A streamed request whose provider has not answered after STREAM_COMMIT_AFTER -# seconds gets a 200 event stream at once, then SSE comment lines every STREAM_KEEPALIVE seconds -# until the provider answers; the provider's stream is then relayed unchanged. A late provider -# error becomes the stream error event of that API. Fast answers (and all errors that arrive -# within STREAM_COMMIT_AFTER) are relayed exactly as before, status code included. -STREAM_COMMIT_AFTER = 3.0 -STREAM_KEEPALIVE = 5.0 -CLIENT_POLL = 0.5 # how often a waiting request checks that its caller is still connected - - -def client_gone(sock): - """True once the caller closed its connection (readable with EOF) while we wait for the provider.""" - try: - readable, _, _ = select.select([sock], [], [], 0) - return bool(readable) and sock.recv(1, socket.MSG_PEEK) == b"" - except OSError: - return True - - -def stream_error(path, message, status=None): - """One SSE error event in the format the API's official SDK raises on.""" - if path == "/v1/messages": - body = {"type": "error", "error": {"type": "api_error", "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - if path == "/v1/responses": - # Official ResponseErrorEvent fields, plus an "error" object: the Python SDK raises only on that key. - body = {"type": "error", "code": str(status or "upstream_error"), "message": message, "param": None, - "error": {"type": "upstream_error", "code": str(status or "upstream_error"), "message": message}} - return b"event: error\ndata: " + json.dumps(body).encode() + b"\n\n" - body = {"error": {"message": message, "type": "upstream_error", "code": status}} - return b"data: " + json.dumps(body).encode() + b"\n\n" - - -HOP_BY_HOP = { - "host", "content-length", "connection", "transfer-encoding", "keep-alive", "accept-encoding", - "proxy-authorization", "proxy-connection", "upgrade", "te", "trailer", -} - - -def validate_upstream(upstream, *, fixture=False): - """Return the parsed upstream; reject credentials, queries and fixture-only routes.""" - parsed = urlsplit(upstream) - if ( - parsed.scheme not in {"https", "http"} - or not parsed.hostname - or parsed.username - or parsed.password - or parsed.query - or parsed.fragment - ): - raise ValueError("Model upstream must be a plain http(s) base URL without credentials") - try: - loopback = ipaddress.ip_address(parsed.hostname).is_loopback - except ValueError: - loopback = parsed.hostname.lower() == "localhost" - if loopback and not fixture: - raise ValueError("A loopback model upstream is restricted to explicit local fixtures") - if parsed.hostname == GOOGLE_HOST and parsed.scheme != "https": - raise ValueError("Google requires TLS") - return parsed - - -def routing_headers(value): - """Parse CI_MODEL_HEADERS: a JSON object of allowlisted, non-secret routing headers.""" - headers = json.loads(value or "{}") - if (not isinstance(headers, dict) - or any(not isinstance(k, str) or k.lower() not in ROUTING_HEADERS for k in headers) - or any(not isinstance(v, str) or not v or any(c in v for c in "\r\n") for v in headers.values())): - raise ValueError(f"CI_MODEL_HEADERS accepts only {sorted(ROUTING_HEADERS)} with plain string values") - return {k.lower(): v for k, v in headers.items()} - - -def compatible_body(value, upstream=GOOGLE, *, path="/v1/chat/completions", model=None): - if not isinstance(value, dict) or not isinstance(value.get("model"), str) or not value["model"]: - raise ValueError("A JSON request with a model name is required") - if model and value["model"] != model: - raise ValueError("The gateway serves only the evaluated model") - if SERVER_SIDE_FIELDS & set(value): - raise ValueError("Provider-side search/fetch/execution fields are not allowed") - if remote_reference({k: v for k, v in value.items() if k != "tools"}): - raise ValueError("Remote content references (URLs the provider would fetch) are not allowed") - tools = value.get("tools") or [] - if not isinstance(tools, list) or any( - not isinstance(tool, dict) or tool.get("type") not in CLIENT_TOOL_TYPES[path] for tool in tools): - raise ValueError("Only client-executed function tools are allowed") - if urlsplit(upstream).hostname == GOOGLE_HOST: - return {key: item for key, item in value.items() if key != "store"} - return value - - -def server(upstream=GOOGLE, *, host="0.0.0.0", port=8003, fixture=False, audit=None, extra_headers=None, - model=None): - parsed = validate_upstream(upstream, fixture=fixture) - extra_headers = routing_headers(json.dumps(extra_headers or {})) - base_path = parsed.path.rstrip("/") - lock = threading.Lock() - - class Handler(BaseHTTPRequestHandler): - def log_message(self, *_args): - pass - - def do_GET(self): - if self.path != "/health": - self.send_error(404) - return - self.send_response(200) - self.send_header("Content-Type", "application/json") - self.end_headers() - self.wfile.write(b'{"ok":true}') - - def do_POST(self): - target = ROUTES.get(self.path) - if target is None: - self.send_error(404) - return - try: - if self.headers.get("Transfer-Encoding") or not self.headers.get("Content-Length"): - raise ValueError("A complete JSON Content-Length body is required") - length = int(self.headers["Content-Length"]) - if not 0 < length <= MAX_BODY: - raise ValueError("Request body size out of bounds") - incoming = json.loads(self.rfile.read(length)) - outgoing = compatible_body(incoming, upstream, path=self.path, model=model) - payload = json.dumps(outgoing, ensure_ascii=False, allow_nan=False).encode() - except (ValueError, TypeError): - self.send_error(400, "Unsupported model gateway request") - return - if audit is not None: - if not fixture: - raise RuntimeError("Provider body capture is forbidden outside fixtures") - with lock: - audit(incoming, outgoing) - connection = ( - http.client.HTTPSConnection if parsed.scheme == "https" else http.client.HTTPConnection - )(parsed.hostname, parsed.port, timeout=None) - headers = {key: value for key, value in self.headers.items() if key.lower() not in HOP_BY_HOP} - sent = {key.lower() for key in headers} - headers.update({key: value for key, value in extra_headers.items() if key not in sent}) - headers.update({"Content-Length": str(len(payload)), "Content-Type": "application/json", - # Plain bytes from the provider (the caller's Accept-Encoding is dropped above): a - # slow stream is answered with the gateway's own headers, so a provider - # Content-Encoding (Google gzips streams on request) could not be passed on. - "Accept-Encoding": "identity"}) - # The upstream call runs in a worker so a slow streamed answer can be kept alive (see - # STREAM_KEEPALIVE): Harbor's agent egress proxy drops a connection that stays silent ~15 s. - result = {} - done = threading.Event() - - abort_lock = threading.Lock() - provider_sock = {} # the raw provider socket; http.client hands it to the response when the body has - # no Content-Length (streams), after which connection.sock is None - - def call(): - try: - connection.connect() - with abort_lock: - provider_sock["sock"] = connection.sock - if provider_sock.get("aborted"): - raise ConnectionAbortedError("caller disconnected before the request was sent") - connection.request("POST", base_path + target, payload, headers) - result["response"] = connection.getresponse() - except (OSError, http.client.HTTPException) as error: - result["error"] = error - finally: - done.set() - - def abort_upstream(): - # Shut the provider socket down (not just close it) so a read blocked in another thread returns - # and the provider sees the disconnect and can stop a generation nobody will read. - with abort_lock: - provider_sock["aborted"] = True - sock = provider_sock.get("sock") or connection.sock - if sock is not None: - try: - sock.shutdown(socket.SHUT_RDWR) - except OSError: - pass - connection.close() - - relay_done = threading.Event() - - def watch_caller(): - # While the provider's body is relayed, a caller hang-up is otherwise noticed only at the next - # write, which may never come if the provider stalls: check the caller every CLIENT_POLL s. - while not relay_done.wait(CLIENT_POLL): - if client_gone(self.connection): - abort_upstream() - return - - def wait_upstream(seconds=None): - """Wait for the provider; False if the caller hung up first (the upstream is then aborted).""" - deadline = None if seconds is None else time.monotonic() + seconds - while not done.is_set(): - step = CLIENT_POLL if deadline is None else min(CLIENT_POLL, deadline - time.monotonic()) - if step <= 0: - return True - if done.wait(step): - break - if client_gone(self.connection): - raise ConnectionAbortedError("caller disconnected") - return True - - threading.Thread(target=call, daemon=True).start() - try: - streamed = incoming.get("stream") is True - wait_upstream(STREAM_COMMIT_AFTER if streamed else None) - if done.is_set() or not streamed: - wait_upstream() - if "error" in result: - # No retry: an ambiguous upstream attempt stays ambiguous. - self.close_connection = True - return - response = result["response"] - self.send_response(response.status, response.reason) - for key, value in response.getheaders(): - if key.lower() not in {"transfer-encoding", "connection", "keep-alive", "content-length"}: - self.send_header(key, value) - self.send_header("Connection", "close") - self.end_headers() - else: - # Slow streamed answer: commit an event stream now and send SSE comments (ignored - # by every SSE client) until the provider answers. - self.send_response(200) - self.send_header("Content-Type", "text/event-stream") - self.send_header("Cache-Control", "no-cache") - self.send_header("Connection", "close") - self.end_headers() - self.wfile.flush() - while not done.is_set(): - wait_upstream(STREAM_KEEPALIVE) - if not done.is_set(): - self.wfile.write(b": keepalive\n\n") - self.wfile.flush() - response = result.get("response") - encoding = (response.getheader("Content-Encoding") or "identity").strip().lower() if response else "" - if response is not None and response.status == 200 and encoding != "identity": - # Our headers are already sent without Content-Encoding: never relay bytes the caller - # cannot decode; fail visibly instead. - self.wfile.write(stream_error(self.path, f"Upstream sent Content-Encoding {encoding!r} " - "despite Accept-Encoding: identity", 502)) - self.wfile.flush() - self.close_connection = True - return - if response is None or response.status != 200: - status = getattr(response, "status", None) - detail = response.read(4096).decode("utf-8", "replace") if response is not None else "" - message = (f"Upstream HTTP {status}: {detail}" if response is not None - else f"Upstream connection error: {type(result.get('error')).__name__}") - self.wfile.write(stream_error(self.path, message, status)) - self.wfile.flush() - self.close_connection = True - return - threading.Thread(target=watch_caller, daemon=True).start() - while data := response.read1(65536): - self.wfile.write(data) - self.wfile.flush() - self.close_connection = True - except (OSError, http.client.HTTPException, ValueError): - # ValueError: the watchdog closed the upstream response under a blocked read. - self.close_connection = True - finally: - relay_done.set() - abort_upstream() - - return ThreadingHTTPServer((host, port), Handler) - - -def main(): - parser = argparse.ArgumentParser(description=__doc__) - parser.add_argument("--host", default="0.0.0.0") - parser.add_argument("--port", type=int, default=8003) - parser.add_argument("--fixture-upstream", help="Explicit local mock only") - args = parser.parse_args() - upstream = args.fixture_upstream or os.environ.get("CI_MODEL_UPSTREAM") or GOOGLE - owned = server(upstream, host=args.host, port=args.port, fixture=bool(args.fixture_upstream), - extra_headers=routing_headers(os.environ.get("CI_MODEL_HEADERS")), - model=os.environ.get("CI_MODEL_NAME") or None) - print(json.dumps({"ready": True, "port": owned.server_port, "fixture": bool(args.fixture_upstream), - "upstream_host": urlsplit(upstream).hostname}), flush=True) - owned.serve_forever() - - -if __name__ == "__main__": - main()